[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

more about filtering and sorting


Subject: more about filtering and sorting
From: Linda van den Brink <lvdbrink@xxxxxxx>
Date: Tue, 30 Mar 1999 10:22:44 +0200

Hi all, 

I succeeded in processing nodes multiple times, so that I could produce
several HTML tables with different sorting of the same data. My next steps
are giving me more problems to achieve... 

I have my list of documents in XML format, looking something like this: 

<contents>
  <document lang="french" cat="install">
    <nr>7160</nr>
    <language>french</language>
    <category>2install</category>
    <title>Guide d'utilisation Baan Enterprise Decision Navigator</title>
    <url>..\..\documents\fr\U7160BFR.pdf</url>
  </document>
  
  <document lang="dutch" cat="manual">
    <nr>7160</nr>
    <language>dutch</language>
    <category>3manual</category>
    <title>Gebruikershandleiding Baan Enterprise Decision Navigator</title>
     <url>..\..\documents\nl\U7160BNL.pdf</url>vvv
  </document>
</contents>

I have documents in different languages and different categories. I want to
produce three HTML tables for each language: one sorted by title, one sorted
by nr, and one sorted by category. Now, I want to do this for each language.
So I must somehow do a repeated filtering for each language and then do
three sortings for each language. What's the easiest way to do this? 

My current stylesheet is below. This version generates the three sorted
tables for german documents only. How do I add templates for the other
languages? I want to keep my stylesheet as short as possibly, because I can
have up to 12 languages... 

===================================
<xsl:stylesheet
   xmlns:xsl="http://www.w3.org/TR/WD-xsl">

<xsl:template match="/">
	<xsl:apply-templates select="contents"/>
</xsl:template>

<!-- als het werkt, nog comments toevoegen -->

<xsl:template match="contents">
	<table cellspacing="0" cellpadding="0">
		<xsl:apply-templates select="document[language='german']">
			<xsl:sort select="title"/>
		</xsl:apply-templates>
	</table>
	<table cellspacing="0" cellpadding="0">
		<xsl:apply-templates select="document[language='german']">
			<xsl:sort select="nr"/>
		</xsl:apply-templates>
	</table>
	<table cellspacing="0" cellpadding="0">
		<tr><td colspan="3" class="cat">Release
Information</td></tr>
		<xsl:apply-templates select="document[category='1release'
and language='german']">
			<xsl:sort select="category"/>
			<xsl:sort select="nr"/>
		</xsl:apply-templates>
		<tr><td colspan="3" class="cat">Installation
Guides</td></tr>
		<xsl:apply-templates select="document[category='2install'
and language='german']">
			<xsl:sort select="category"/>
			<xsl:sort select="nr"/>
		</xsl:apply-templates>
		<tr><td colspan="3" class="cat">Manuals/Guides</td></tr>
		<xsl:apply-templates select="document[category='3manual' and
language='german']">
			<xsl:sort select="category"/>
			<xsl:sort select="nr"/>
		</xsl:apply-templates>
	</table>
</xsl:template>

<xsl:template match="document">
	<tr>
		<xsl:apply-templates select="nr"/>
		<xsl:apply-templates select="title"/>
	</tr>
</xsl:template>

<xsl:template match="nr">
    <td><em>
    <xsl:apply-templates/>
    </em></td>
</xsl:template>

<xsl:template match="title">
    <td>
    <xsl:apply-templates/>
    </td>
    <td><xsl:apply-templates select="ancestor(document)/url"/></td>
</xsl:template>    

<xsl:template match="url">
	<span class="origin" onClick="conloc.href=('..\..\..\docs{.}')">Open
document</span>
</xsl:template>

</xsl:stylesheet>

==========================================


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



Current Thread
Keywords
xml