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

Sorting the second level

Subject: Sorting the second level
From: "Ivo" <ivo_wiens@xxxxxxxxxxx>
Date: Thu, 8 Nov 2001 17:38:23 -0600
xml second level
Hi All,

Here's my problem:
I have an xml that looks like this:
<courses>
 <course>
  <outline />
  <Product>Access</Product>
  <manufacturer>Microsoft</manufacturer>
  <coursecode>CF_D111EN-IN</coursecode>
  <lang>English</lang>
  <title>Fundamentals</title>
  <product>Access</product>
   </course>

...continued by many other <course> tags....

I have all the xml nodes already sorted first by the <lang> node, then by
<manufacturer>.
My desired output is this:

English
   Microsoft
        Access Fundamentals
        Word Level 2
   Corel
        WordPerfect Level 3
    Lotus
        Lotus Notes Fundamentals

French
    Microsoft
        Access Level 2
        Excel Level 3
    Lotus
        WordPro 5 Fundamentals

I am using the following statements to create the Lang Titles (ie. French,
English, etc...):

<xsl:if test="not(preceding-sibling::course/lang = lang)">
<tr><xsl:value-of select="lang" /></tr>

I've also done the same with manufacturer:

<xsl:if test="not(preceding-sibling::course/manufacturer = manufacturer)">
<tr><xsl:value-of select="manufacturer" /></tr>

However, the above (manufacturer) only works on the first language. My
output ends up like this:

English
   Microsoft
        Access Fundamentals
        Word Level 2
   Corel
        WordPerfect Level 3
    Lotus
        Lotus Notes Fundamentals
French
        Access Level 2
        Excel Level 3
        WordPro 5 Fundamentals

And any language that is not listed first doesn't get split into
manufacturer groups. How could I work around that? I understand this is a
little confusing, feel free to ask me for more info...


Here's my complete xsl:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
 <xsl:template match="/">
  <h1>Course Search Results</h1>
  <table cellpadding="3" cellspacing="0" width="90%">
   <xsl:apply-templates select="//course"/>
   <td><STRONG>* Instructor Guide version also

available.</STRONG></td>
   </tr>
  </table>
  </xsl:template>
 <xsl:template match="course">
 <xsl:if test="not(preceding-sibling::course/lang = lang)">
 <tr>
 <td><font class="language" size="4pt"><STRONG><xsl:value-of select="lang"

/></STRONG></font></td>
 </tr>
  <tr>
    <th>Course</th>
    <th></th>
    <th>Duration</th>
    <th></th>
    <th></th>
    <th>Status</th>
   </tr>
 </xsl:if>
 <xsl:variable name="currvar"><xsl:value-of select="sort2bycurrent"

/></xsl:variable>
 <xsl:variable name="igavailvar"><xsl:value-of select="igavailable"

/></xsl:variable>
 <xsl:choose>
 <xsl:when test="(instructorguide/text())">
 </xsl:when>
 <xsl:when test="$currvar>'3'">
 </xsl:when>
 <xsl:otherwise>
 <xsl:if test="not(preceding-sibling::course/manufacturer = manufacturer)">
 <tr>
 <td><font size="3pt"><u><STRONG><xsl:value-of select="manufacturer"

/></STRONG></u></font></td>
 </tr>
 </xsl:if>
   <tr>
   <td><xsl:text> </xsl:text><xsl:value-of select="product"

/><xsl:text> </xsl:text><xsl:value-of select="version" /><xsl:text>

</xsl:text><xsl:value-of select="title"/><xsl:text> </xsl:text><xsl:value-of

select="snapshots"/><xsl:if test="$igavailvar='True'">*</xsl:if></td>
   <td>
   <xsl:choose>
   <xsl:when test="(outline/text())">
   <a><xsl:attribute

name="href">http://www.classroomfactory.com/outliner.asp?code=<xsl:value-of

select="coursecode"/></xsl:attribute>Outline</a>
   </xsl:when>
   </xsl:choose>
   </td>
   <td><xsl:value-of select="duration" /> day</td>
   <td><A HREF="ordermaterial.asp" target="_blank">order</A></td>
   <td><xsl:text>  </xsl:text></td>
   <xsl:variable name="statusvar"><xsl:value-of

select="devstatus"/></xsl:variable>
   <xsl:choose>
   <xsl:when test="$statusvar='WIP'">
   <xsl:variable name="datevar"><xsl:value-of

select="releasedate"/></xsl:variable>
   <td>Q<xsl:value-of

select="ceiling(substring-before(releasedate,'/') div 4)"/> - 2001</td>
   </xsl:when>
   <xsl:otherwise>
   <td><xsl:value-of select="devstatus"/></td>
   </xsl:otherwise>
   </xsl:choose>
  </tr>
 </xsl:otherwise>
 </xsl:choose>
 </xsl:template>
</xsl:stylesheet>









 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.