I'd write the contents of the files into a variable and then work on the
contents of the variable. That way, you get all the content in one place,
so that you can sort all of it.
Jay Bryant
Bryant Communication Services
(presently consulting at Synergistic Solution Technologies)
cookie king <cookieking(_at_)comcast(_dot_)net>
06/29/2005 07:57 PM
Please respond to
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
To
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
cc
Subject
Spam:[xsl] sorting issue
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(., '

', ' ')"/>
</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> </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>
--~--
--~------------------------------------------------------------------
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>
--~--