xsl-list
[Top] [All Lists]

sorting issue

2005-06-29 17:57:04
Recently submitted a post requesting help with sorting. my situation is still the same. i am merging many documents. i get the sort to work but not correctly. it appears to be looking at only the first node of each file and sorting the files according to the first node. i need to sort each individual file first. then merge the sort of all file, or sort each file then merge all.

mastermerge.xsl
=====================================
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
   <xsl:preserve-space elements="text"/>
   <xsl:template match="masterfile">
       <merged>
<table style="border:1px solid #000000;border-collapse:collapse"> <xsl:apply-templates select="document(doc/@filename)/client">
                   <!-- <xsl:sort select="name"/> -->
                   <xsl:sort select="subclient/name/lname" />
               </xsl:apply-templates>
           </table>
       </merged>
   </xsl:template>
   <xsl:template match="text()">
       <xsl:value-of select="translate(., '&#xA;&#xD;', '  ')"/>
   </xsl:template>
   <xsl:template match="client/subclient">
       <xsl:copy>
           <!-- <tr>
               <th>
                   <xsl:apply-templates select="title"/>
               </th>
           </tr> -->
           <tr>
               <td style="border:1px solid #000000">
                   <!-- <xsl:apply-templates select="@*|node()"/> -->
                   <!-- <xsl:apply-templates select="name"/> -->
                   <xsl:for-each select="name">
                       <xsl:sort select="lname" order="ascending"/>
                       <xsl:value-of select="fname"/>
                       <xsl:text>  </xsl:text>
                       <xsl:value-of select="lname"/>
                   </xsl:for-each>
                   <!--
                       <xsl:apply-templates select="lname"/> -->
               </td>
               <td style="border:1px solid #000000">
                   <xsl:apply-templates select="phones"/>
               </td>
               <td style="border:1px solid #000000">
                   <xsl:apply-templates select="address"/>
               </td>
           </tr>
       </xsl:copy>
   </xsl:template>
   <!--  <xsl:for-each select="name">
       <xsl:sort select="lname"/>
             <xsl:value-of select="fname"/>
       </xsl:for-each> -->
   <xsl:template match="address">
       <xsl:for-each select="line">
           <xsl:apply-templates/>
           <br/>
       </xsl:for-each>
       <xsl:value-of select="url"/>
       <br/>
       <xsl:value-of select="email"/>
       <br/>
   </xsl:template>
   <xsl:template match="name">
       <xsl:apply-templates/>
       <xsl:text>&#160;</xsl:text>
   </xsl:template>
</xsl:stylesheet>
====================================
file1.xml
====================================

<client>
   <subclient>
       <title>A</title>
   </subclient>
   <subclient>
       <name>
           <fname>Jack</fname>
           <lname>John</lname>
       </name>
       <phones>
           <phone/>
           <ext/>
           <fax/>
       </phones>
       <address>
       <line>address 1</line>
       <line>address 2</line>
       <url>www.what.com</url>
       <email/></address>
   </subclient>
</client>
===================================
masterfile.xml
===================================
<masterfile>
   <doc filename="file1.xml"/>
   <doc filename="file2.xml"/>
</masterfile>


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>