|
Subject: Re: [xsl] What is the simplest method for using xsl:sort without losing attribute names and values? From: Martin Honnen <Martin.Honnen@xxxxxx> Date: Sun, 20 Jul 2008 12:59:42 +0200 |
I want to do a simple sort without losing either elements or attributes. The xls style sheet I have written works, but there must be a more
succinct method. One element <Cat> has four attributes (two optional), the other <Person> has one optional attribute. When the templates for <Cat> and <Person> are not present in my style sheet, I lose the attributes but not the elements themselves.
<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates>
<xsl:sort select="Year" />
<xsl:sort select="IssueNumber"/>
<xsl:sort select="Page" />
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates>
<xsl:sort select="Year" />
<xsl:sort select="IssueNumber"/>
<xsl:sort select="Page" />
</xsl:apply-templates>
</xsl:copy>
</xsl:template> <xsl:template match="foo">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates>
<xsl:sort select="Year" />
<xsl:sort select="IssueNumber"/>
<xsl:sort select="Page" />
</xsl:apply-templates>
</xsl:copy>
</xsl:template>Martin Honnen http://JavaScript.FAQTs.com/
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] What is the simplest meth, Mukul Gandhi | Thread | Re: [xsl] What is the simplest meth, Mark Wilson |
| Re: [xsl] Fwd: xml/xslt line break, Martin Honnen | Date | Re: [xsl] Fwd: xml/xslt line break, Taly |
| Month |