|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: xsl:sort by element name
>
> Dear List,
> I am trying to sort my output nodes based on their element name.
>
Mike,
This will sort all children of <root> by their name()
==xml==
<root>
<a>x</a>
<c>x</c>
<b>x
<d>x</d>
</b>
<z>x</z>
<g>x</g>
</root>
==output==
<a /><b /><c /><d /><g /><z />
==xsl==
<xsl:template match="/">
<xsl:apply-templates select="root//*">
<xsl:sort select="name()"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="*">
<xsl:copy/>
</xsl:template>
cheers
andrew
>
> Dear List,
> I am trying to sort my output nodes based on their element name.
>
> Could someone give me a hint on this one?
>
> Mike F.
>
>
> XML:
> <LLL>
> <C1012>...C-data...</C1012>
> <C1012>...A-data...</C1012>
> <C1012>...B-data...</C1012>
> </LLL>
>
> Output should be:
> <LLL>
> <C1012>...A-data...</C1012>
> <CC1012>...B-data...</CC1012>
> <CCC1012>...C-data...</CCC1012>
> </LLL>
>
>
> XSL:
> <xsl:template select="/">
> <xsl:for-each select="/*">
> <xsl:sort select="name()"/>
> <xsl:apply-templates select="C1012"/>
> </xsl:for-each>
> </xsl:template>
>
> __________________________________________________
> Do You Yahoo!?
> Try FREE Yahoo! Mail - the world's greatest free email!
> http://mail.yahoo.com/
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








