This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Infinte nesting with sorting
- From: Oscar Rueda <orp at intras dot es>
- To: XSL-List at lists dot mulberrytech dot com
- Date: Fri, 11 Jan 2002 11:34:30 +0100
- Subject: [xsl] Infinte nesting with sorting
- Organization: IDES
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hello to all
I've got a XML file like this:
<Issue id="2"
<Chapter id="2">
<Chapter id="1">
<Chapter id="2">
<Chapter id="2" />
<Chapter id="1" />
</Chapter>
</Chapter>
</Chapter>
<Chapter id="1">
<Issue id="1">
................
I want the output indented and sorted by chapter id, just like
<Issue 1>
<Issue 2>
<Chapter 1>
<Chapter 2>
<Chapter 1>
<Chapter 2>
<Chapter 1>
<Chapter 2>
.....
I've tried with the following XSL, that goes well with the indenting and
sorting the issues
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<xsl:apply-templates select="//Issue" order-by="+@id"/>
<xsl:apply-templates select="//Chapter" />
</xsl:template>
<xsl:template match="Issue"><p>
<xsl:value-of select="@id" />
<xsl:apply-templates /></p>
</xsl:template>
<xsl:template match="Chapter">
<BLOCKQUOTE>
<xsl:value-of select="@id" />
<xsl:apply-templates />
</BLOCKQUOTE>
</xsl:template>
</xsl:stylesheet>
But sorting the chapters looks painful, does anyone have a clue?
By the way, I'm using IE5, so I can't use <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
Thanks to all
Oscar Rueda
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list