G. Ralph Kuntz, MD, MS wrote:
> How do people deal with out-of-order document? Let me clarify.
>
> Let's say we have an input document having the following format:
>
> <document>
> section 1
> section 2
> section 3
> </document>
>
> we want the resulting output document to have the structure
>
> <document>
> section 3
> section 2
> section 1
> </document>
>
> Since the xsl template matching will match section 1, then section 2,
> etc. how do we get the output into the format we want?
Here is an example, assuming the document element has section child
elements like this
<document>
<section>section 1</section>
<section>section 2</section>
<section>section 3</section>
</document>
then you can process them and sort in descending order
<xsl:stylesheet
xmlns

sl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl

utput method="xml" indent="yes"/>
<xsl:template match="document">
<xsl:copy>
<xsl:apply-templates select="section">
<xsl:sort select="position()" order="descending"
data-type="number"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
to reverse the original order.
--
Martin Honnen
http://JavaScript.FAQTs.com/