![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xsl Archive Home >Recent entries [Thread Prev] >Thread Next - Re: sorting by attribute value sorting by attribute valueTo: NULL Date: 2/2/2007 10:36:00 AM
Greetings,
I need to sort this XML by the value in the sequence attribute and I
was hoping for a little help as the XSL i have created is not doing
the job.
<AnswerKey>
<question id="100">
<fragment sequence="3">Some Text</fragment>
<fragment sequence="1">Some Text</fragment>
<fragment sequence="2">Some Text</fragment>
</question>
<question id="101">
<fragment sequence="3">Some Text</fragment>
<fragment sequence="2">Some Text</fragment>
<fragment sequence="1">Some Text</fragment>
</question>
</AnswerKey>
I need each question element to contain the fragment elements, but
sorted numerically by sequence.
Here is the XSL I am using:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="/">
<AnswerKey>
<xsl:for-each select="AnswerKey/question">
<xsl:for-each select="fragment">
<xsl:sort data-type="text" select="@sequence"/>
<xsl:copy-of select="."/>
</xsl:for-each>
<xsl:copy-of select="."/>
</xsl:for-each>
</AnswerKey>
</xsl:template>
</xsl:stylesheet>
I think the problem is the second "copy-of". I can't seem to get the
syntax correct for what I am looking to do. Can anyone help? Thanks!
| ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
