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

Order-by or sort

Subject: Order-by or sort
From: cookie king <cookieking@xxxxxxxxxxx>
Date: Mon, 27 Jun 2005 20:45:03 -0400
xsl for each order by
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@xxxxxxxxxxxxxxxx</email>
       </address>
   </lhp:Row>
...
</lhp:Root>

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.