Hi,
The xsl:for-each element does not support the order-by
attribute. Use the xsl:sort instruction instead.
<xsl:for-each select="name">
<xsl:sort select="lname"/>
<xsl:value-of select="fname"/>
</xsl:for-each>
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] Order-by or sort
06/28/2005 06:15
AM
Please respond
to xsl-list
I am merging several xml documents. i am trying to sort them by Last
name but have been unsuccessful. any help would be greatly appreciated.
i have attached the xsl and one sample xml. the format on all xml docs
are the same
merge.xsl
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:lhp="http://ananas.org/2003/tips/photo">
<xsl:output method="html"/>
<!-- *** -->
<!-- include content-->
<!-- <xsl:include href="../_borders/bottom.htm"/> -->
<!-- *** -->
<!-- *** -->
<xsl:template match="lhp:index">
<html xmlns:mso="urn:schemas-microsoft-com:office:office"
xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252"/>
<meta name="author" content="kookie"/>
<title>Financial Contact List</title>
<!-- *** -->
<!-- *** -->
<style>
table.table td {
border: 1px solid #595F91; }
</style>
<!-- START RELATIVE LINKS -->
<link rel="stylesheet" type="text/css"
href="../css/styles.css"/>
<script language="JavaScript"
src="../JavaScript/functions.js"/>
<script language="JavaScript"
src="../JavaScript/trail.js"/>
<!-- END RELATIVE LINKS -->
<!-- *** -->
<!-- *** -->
</head>
<!-- *** -->
<!-- *** -->
<body class="mapblock" topmargin="0">
<!-- START BACK-TO-TOP LINK SCRIPT REFERENCE -->
<script src="../JavaScript/TrueDriftBottom.js"/>
<!-- END BACK-TO-TOP LINK SCRIPT REFERENCE -->
<!-- START TRAIL SCRIPT REFERENCE -->
<!-- edited out for testing
<div id="trailMenu"
style="position:absolute; left:0px; top:2px">
<script
language="JavaScript" type="text/javascript">
document.write(makeTrailMenu());
</script>
</div> -->
<!-- END TRAIL SCRIPT REFERENCE -->
<p class="description">Financial Contact List
<!-- <xsl:for-each select="Acronym/description">
<xsl:apply-templates/>
</xsl:for-each>-->
</p>
<p class="updated">Updated:
<script type="text/javascript">writeDateModified (true);</script>
</p>
<div style="width:85%;margin-left:28px">
<table>
<tr>
<td>
<a href="index.xml">All Contact Lists</a> |
</td>
<td>
<a href="indexDADS.xml">DADS</a> |
</td>
<td>
<a href="indexDARS.xml">DARS</a> |
</td>
<td>
<a href="indexDFPS.xml">DFPS</a> |
</td>
<td>
<a href="indexDSHS.xml">DSHS</a> |
</td>
<td>
<a href="indexHHSC.xml">HHSC</a>
</td>
</tr>
</table>
</div>
<div style="width:85%;margin-left:20px">
<!-- *** -->
<!-- *** -->
<table class="table">
<!-- *** -->
<!-- *** -->
<col/>
<col/>
<tr>
<th>Name</th>
<th>Position</th>
<th>Phone</th>
<th>Ext</th>
<th>Email</th>
</tr>
<!-- *** -->
<!-- *** -->
<xsl:apply-templates/>
</table>
</div>
<!-- include content -->
<!-- <xsl:call-template name="Content"/> -->
<!-- -->
</body>
</html>
</xsl:template>
<xsl:template match="lhp:entry">
<xsl:apply-templates select="document(concat(.,'.xml'))"/>
</xsl:template>
<xsl:template match="lhp:Root/lhp:Row">
<xsl:for-each select="lhp:title">
<tr>
<th colspan="5" style="text-align:center">
<xsl:apply-templates/>
</th>
</tr>
</xsl:for-each>
<tr><!-- alternate row color -->
<xsl:attribute name="class"><xsl:choose><xsl:when
test="position() mod 2 = 1">tablerowon</xsl:when><xsl:when
test="position() mod 2 =
0">tablerowoff</xsl:when></xsl:choose></xsl:attribute>
<td class="class">
<xsl:apply-templates select="name"/>
<!-- <xsl:for-each select="name" >
<xsl:apply-templates/>
</xsl:for-each> -->
</td>
<td class="class">
<xsl:for-each select="position">
<xsl:apply-templates/>
</xsl:for-each>
</td>
<td class="class">
<xsl:apply-templates select="phones/phone"/>
</td>
<td class="class">
<!-- <xsl:if test="ext[.!='']"> want to add x b4
extension.. does not work below
<b>x-</b>
<xsl:value-of select="ext"/>
</xsl:if>-->
<xsl:apply-templates select="phones/ext"/>
</td>
<td class="class">
<xsl:apply-templates select="address"/>
</td>
</tr>
</xsl:template>
<xsl:template match="lhp:Root/lhp:Row/phones">
<xsl:for-each select="phone">
<xsl:apply-templates/>
</xsl:for-each>
<xsl:if test="ext[.!='']">
<b>x-</b>
<xsl:value-of select="ext"/>
</xsl:if>
</xsl:template>
<xsl:template match="lhp:Root/lhp:Row/address">
<a>
<xsl:attribute name="href"><xsl:value-of
select="url"/></xsl:attribute>
<xsl:attribute name="title"><xsl:value-of
select="url"/></xsl:attribute>
<xsl:value-of select="url"/>
<!-- DISPLAY- Hypertext -->
</a>
<xsl:if test="(url[.!='']) and (email[.!=''])">
<br/>
</xsl:if>
<xsl:if test="(line[.!='']) and (email[.!=''])">
<br/>
</xsl:if>
<a>
<xsl:attribute name="href">mailto:
<xsl:value-of select="email"/></xsl:attribute>
<xsl:attribute name="title"><xsl:value-of
select="email"/></xsl:attribute>
<xsl:value-of select="email"/>
</a>
</xsl:template>
<xsl:template match="name">
<!-- <xsl:for-each select="name" order-by="+ lname"> this does
not
work -->
<xsl:value-of select="fname"/>
<xsl:text>
</xsl:text>
<xsl:value-of select="mname"/>
<xsl:if test="(mname[.!=''])">
<xsl:text>
</xsl:text>
</xsl:if>
<xsl:value-of select="lname"/>
<!-- </xsl:for-each>-->
</xsl:template>
</xsl:stylesheet>
//================================================
DADSContactList.xml
<lhp:Root xmlns:lhp="http://ananas.org/2003/tips/photo">
<lhp:Row>
<lhp:title>DADS Contact List</lhp:title>
</lhp:Row>
<lhp:Row>
<name>
<fname>Joe</fname>
<mname/>
<lname>James</lname>
</name>
<position>Business Analyst</position>
<phones>
<phone>439-2058</phone>
<ext/>
</phones>
<address>
<email>joe(_at_)Dads(_dot_)state(_dot_)fl(_dot_)us</email>
</address>
</lhp:Row>
...
</lhp:Root>
--~------------------------------------------------------------------
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>
--~--