You could have a function with a boolean result to test if an element is
special or ordinary:
<xsl:function name="f:is-ordinary" as="xs:boolean">
<xsl:param name="element" as="element()"/>
<xsl:sequence select="not(self::(elem1 | elem2 | elem3 ...))"/> <!-- 4.0
syntax -->
</xsl:function>
and then use this as a sort key:
<xsl:apply-templates select="sort(*, (), f:is-ordinary#1)"/>
etc. Note false sorts before true.
Michael Kay
Saxonica
> On 11 Mar 2025, at 12:40, Michael Mueller-Hillebrand
michael.mueller-hillebrand@xxxxxxxxx <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
wrote:
>
> Hello, dear colleagues,
>
> We have a task to process certain child elements before all other child
nodes are processed. The obvious, simple solution would be something like:
>
> <xsl:apply-templates select="elem1, node() except elem1"/>
>
> But in our case, we have six named elements that should be processed before
all other child nodes. And the repetition of the node list seems not very
nice:
>
> <xsl:apply-templates select="(elem1|elem2|elem3|elem4|elem5|elem6), node()
except (elem1|elem2|elem3|elem4|elem5|elem6)"/>
>
> Yes, I could collect the special elements in a variable and use this.
>
> <xsl:variable name="specialElems"
select="(elem1|elem2|elem3|elem4|elem5|elem6)" as="element()+"/>
> <xsl:apply-templates select="$specialElems, node() except $specialElems"/>
>
> Do you have other suggestions which I cannot see because my brain is not
relaxed enough?
>
> Thanks a lot,
> Michael
>
>
> Michael MC<ller-Hillebrand
> Senior Consultant
> Phone +49 951-20859-752
> Mobil +49 172-819 34 13
> michael.mueller-hillebrand@xxxxxxxxx
<mailto:michael.mueller-hillebrand@xxxxxxxxx>
> www.docufy.de <https://www.docufy.de/> | DOCUFY@LinkedIN
<https://www.linkedin.com/company/3845358/>
> Datenschutz <https://www.docufy.de/datenschutz/>
> DOCUFY GmbH | KirschC$ckerstr. 27 | 96052 Bamberg | Deutschland
> GeschC$ftsfC<hrung: Nadine Prill (CEO) & Daniel Weiskopf (CFO) | Amtsgericht
Bamberg HRB10571
>
> XSL-List info and archive <http://www.mulberrytech.com/xsl/xsl-list>
> EasyUnsubscribe <http://lists.mulberrytech.com/unsub/xsl-list/3500899> (by
email <>)
|