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
--~------------------------------------------------------------------
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>
--~--