[xsl] Rearrange order of processed nodes

Subject: [xsl] Rearrange order of processed nodes
From: "Michael Mueller-Hillebrand michael.mueller-hillebrand@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 11 Mar 2025 12:39:44 -0000
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@docufy
.de>
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

Current Thread