[xsl] sorting problem

Subject: [xsl] sorting problem
From: DPawson@xxxxxxxxxxx
Date: Thu, 25 Oct 2001 13:27:06 +0100
Given xml

   <r id="d0e1588">
      <bibno>050220</bibno>
      <play-time>08:15</play-time>
      <m100>
         <surname>Tootell</surname>
         <f-name>Betty</f-name>
      </m100>
       <m655>
         <cat>Java</cat>
         <term2>Indonesia</term2>
         <term3>Southeast</term3>
         <term4>Asia</term4>
         <term5>Vehicle Failures</term5>
         <term6>Accidents</term6>
         <term7>Air and Space Transport</term7>
         <term8>Public Safety</term8>
         <term9>Social Services</term9>
         <term10>Social Sciences</term10>
      </m655>
      <readers>Gretel Davis</readers>
      </r>

lots of r elements in a <doc> wrapper.

the termX elements are 'inverse' i.e. from specific to general.
they also vary in 'depth' from 2 to 10.

I need to sort the r elements, using a revese order on m655/termX

  <xsl:template match="doc">
    <doc>
      <xsl:apply-templates select="date"/>
    <xsl:for-each select="r">
      <xsl:sort select="m655/term10"/>
     <xsl:sort select="m655/term9"/>
     <xsl:sort select="m655/term8"/>
     <xsl:sort select="m655/term7"/>
     <xsl:sort select="m655/term6"/>
     <xsl:sort select="m655/term5"/>
     <xsl:sort select="m655/term4"/>
     <xsl:sort select="m655/term3"/>
     <xsl:sort select="m655/term2"/>
     <xsl:sort select="m655/term1"/>
     <xsl:sort select="m655/cat"/>

    <!-- Copy the current node -->
    <xsl:copy>
      <!-- Including any attributes it has and any child nodes -->
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:for-each>
</doc>
  </xsl:template>

Sorts out the records, but by nesting.
something like
  a
  b
  ...
  p
  a   (I.e. this is at a lower level than the previous one)
  c
  ...
 


Looking for inspiration as to how I might produce a sort that
works 'across' the differing levels.

Any advice appreciated.

Regards DaveP

********** snip here **********




************snip here************** 

- 

NOTICE: The information contained in this email and any attachments is 
confidential and may be legally privileged. If you are not the 
intended recipient you are hereby notified that you must not use, 
disclose, distribute, copy, print or rely on this email's content. If 
you are not the intended recipient, please notify the sender 
immediately and then delete the email and any attachments from your 
system.

RNIB has made strenuous efforts to ensure that emails and any 
attachments generated by its staff are free from viruses. However, it 
cannot accept any responsibility for any viruses which are 
transmitted. We therefore recommend you scan all attachments.

Please note that the statements and views expressed in this email 
and any attachments are those of the author and do not necessarily 
represent those of RNIB.

RNIB Registered Charity Number: 226227

Website: http://www.rnib.org.uk 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread