I'm trying to do a sort on the following data.
<contents>
<content>
<id>
<text>
</content>
<relatedcontent>
<id>
<text>
</relatedcontent>
</contents>
This is just sample data simplified, but you get the idea. Its two different named nodes that contains the same structure.
Right now I have created two different templates to treat the content and relatedcontent separetly, but then sorting is also done separetly. Is there an easy way to sort both content and relatedcontent on ids? Lets say the <text> contains a text. How could I then list all the <text>-elements of content and relatedcontent sorted by id?
Thanks!
Try something like this
<xsl:foreach select="//content | //relatedcontent">
<xsl:sort select="id" />
<xsl:value-of select="text" />
</xsl:foreach>
I guess the solution lies in the fact that you "join" //content and //relatedcontent into a single node-set using the union operator |
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With