Hi,
I have modified your stylesheet to make it work:
<?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>
<!-- newly added template for client and xsl:sort moved from above template
to here -->
<!-- major change was I modified the select attribute of sort to be
name/lname instead of subclient/name/lname -->
<xsl:template match="client">
<xsl:apply-templates select="subclient">
<xsl:sort select="name/lname" />
</xsl:apply-templates>
</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>
Hope this helps.
Cheers,
prakash
cookie king
<cookieking(_at_)comc To:
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
ast.net> cc: (bcc:
omprakash.v/Polaris)
Subject: [xsl] sorting issue
06/30/2005 06:27
AM
Please respond
to xsl-list
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>
--~--
This e-Mail may contain proprietary and confidential information and is sent
for the intended recipient(s) only.
If by an addressing or transmission error this mail has been misdirected to
you, you are requested to delete this mail immediately.
You are also hereby notified that any use, any form of reproduction,
dissemination, copying, disclosure, modification,
distribution and/or publication of this e-mail message, contents or its
attachment other than by its intended recipient/s is strictly prohibited.
Visit Us at http://www.polaris.co.in
--~------------------------------------------------------------------
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>
--~--