[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

sorting issue

Subject: sorting issue
From: cookie king <cookieking@xxxxxxxxxxx>
Date: Wed, 29 Jun 2005 20:57:04 -0400
cookie king
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>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.