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

Re: xsl:sort now working under unix

Subject: Re: xsl:sort now working under unix
From: Sylvia Murphy <murphys@xxxxxxxx>
Date: Wed, 22 Dec 2004 15:54:12 -0700
unix case
Hi Anton,

that did help. this is of course the streamlined version to see if I could get sort working period. My more complicated real issue still does not work
so there is probably a slightly different syntactical issue.


In my real code, I am combining multiple xml files using:

<?xml version="1.0"?>
<?xml-stylesheet type="text/xml" href="./status_style.xsl"?>
<runs>
<title>Summary of CCSM Production Runs</title>
<case filename="./b30.043.xml"/>
<case filename="./b30.999.xml"/>
<case filename="./b30.100.02.xml"/>
</runs>

the above is what I load in the browser.


an example of one of these xml files is: <case> <name>b30.999</name>

<start_info>hybrid b30.999 year 100</start_info>

<start_year>230</start_year>

<proj_end_year> ?? </proj_end_year>

<res>T45_gx1v3</res>

<description>1870 Control</description>

<working_group>NA</working_group>

<tag>ccsm3_0_rel03</tag>

<history> xlink to WREQ </history>

 <!--running, completed, halted, or aborted-->
 <status>aborted</status>

 <queue>csl_sp8</queue>
</case>


here is the stylesheet. I will need to be able to sort all these cases by various parameters in the xml files:



<?xml version= "1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">


<xsl:template match="/">
<html>
<head>
<title><xsl:value-of select="/runs/title"/></title>
<link rel="stylesheet" type="text/css" href="/cseg/doc.css"></link>
</head>
<body>
<h1> CCSM Production Run Status</h1>
<table cellpadding="4" cellspacing="4" border="1">
<tr bgcolor = "#c6EFF7">
<td>Case</td>
<td>Status</td>
<td>Start Info</td>
<td>Start Year</td>
<td>End Year</td>
<td>Resolution</td>
<td>Tag</td>
<td>Queue</td>
<td>Description</td>
<td>History</td>
</tr>
<xsl:for-each select="/runs/case">
<!--ascending or descending--> <xsl:apply-templates select="document(@filename)/case">
<xsl:sort select="/case/status" data-type = "text" order="descending"/>
</xsl:apply-templates>
</xsl:for-each>
</table>
</body>
</html>


</xsl:template>


<!-- this portion is actually what occurs in the middle of the table--> <xsl:template match="case"> <tr> <td><xsl:value-of select="name"/></td> <xsl:if test="status = 'aborted'"> <td bgcolor="red"><xsl:value-of select="status"/></td> </xsl:if> <xsl:if test="status = 'halted'"> <td bgcolor="#FFCE9C"><xsl:value-of select="status"/></td> </xsl:if> <xsl:if test="status = 'completed'"> <td bgcolor="#EFF8AD"><xsl:value-of select="status"/></td> </xsl:if> <xsl:if test="status = 'running'"> <td bgcolor="#CE84C6"><xsl:value-of select="status"/></td> </xsl:if> <td><xsl:value-of select="start_info"/></td> <td><xsl:value-of select="start_year"/></td> <td><xsl:value-of select="proj_end_year"/></td> <td><xsl:value-of select="res"/></td> <td><xsl:value-of select="tag"/></td> <td><xsl:value-of select="queue"/></td> <td><xsl:value-of select="description"/></td> <td><xsl:value-of select="history"/></td> </tr>

</xsl:template>



</xsl:stylesheet>










Anton Triest wrote:


Hi Sylvia,

   <xsl:for-each select="addressbook">
<!--descending or ascending (default) -->
     <xsl:sort select="age" data-type="number" order="descending"/>
     <xsl:apply-templates/>
   </xsl:for-each>


xsl:sort works on the for-each that precedes it, not on the apply-templates that follows it. So this code will sort the addressbook elements, instead of the address elements. That's why they appear in input-document order. Try replacing the above snippet with something like:

<xsl:for-each select="addressbook">
  <xsl:apply-templates select="address">
      <xsl:sort select="age" data-type="number" order="descending"/>
  </xsl:apply-templates>
</xsl:for-each>

HTH,
Anton

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.