Re: [xsl] Accessing every second node, extract and sort their elements and then not copy the node name

Subject: Re: [xsl] Accessing every second node, extract and sort their elements and then not copy the node name
From: christoph.naber@xxxxxxxxxxx
Date: Tue, 29 Jul 2008 10:18:32 +0200
Hello,

> Trying to convert to a XML document into another, I'm trying to
> figure out how to access every second element node from the document
> root, take and sort all their elements according 2 attributes (
> GroupNumber and ElementNumber)

Some stylesheet code and example select statements would have made
figuring out what you want much easier, but I think you want something
like:

<xsl:apply-templates select="/*/*/*" >
        <xsl:sort select="@GroupNumber" />
        <xsl:sort select="@ElementNumber" />
</xsl:apply-templates>

This selects all elements on the third level, that is, all childnodes of
"every second node", imho better indicated as "nodes on the third level".

But what do you mean with

> without copy the name of the second element name.

?

Simply copying the selected nodes to the result document is done with:
<xsl:template match="/*/*/*">
        <xsl:copy>
                <xsl:copy-of select="@*" />
        </xsl:copy>
</xsl:template>

One can achieve this with a for-each loop too, but that isn't the
declarative XSLT way.

Greetings Christoph



If you are not the intended addressee, please inform us immediately that you
have received this e-mail in error, and delete it. We thank you for your
cooperation.

Current Thread