Subject: Re: help with numbering (xsl:number)
From: "element" <element@xxxxxxxxxxx>
Date: Mon, 17 Jan 2000 11:38:57 +0800
|
Hi, Jerry
You should make two template to match separately for each layer of chapter.
You can't separate the 'chapter' and the 'chapter/chapter' if you select
'//chapter'.
There is a good example in my xsl example of own homepage:
http://www.nease.net/~element/xml/xmltable.xml
Hope you enjoy it.
Ji Yuchun
1370 8989 632
http://www.precomtech.com/jyc
----- Original Message -----
From: Jerry Ventura <jventura@xxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxx>
Sent: Saturday, January 15, 2000 7:10 AM
Subject: help with numbering (xsl:number)
> I've come across an example of how to use xsl:number - but I'm having a
> problem with it. Can someone take a look at this xsl and tell me what I
may
> be doing wrong:
>
>
> <xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>
> <xsl:template match="*|/"><xsl:apply-templates/></xsl:template>
> <xsl:template match="text()|@*"><xsl:value-of select="."/></xsl:template>
> <xsl:template match="/">
> <TABLE BORDER="1">
> <TR><TH>Number</TH><TH>text</TH></TR>
> <xsl:for-each select="//chapter">
> <TR><TD>
> <xsl:number/>
> </TD><TD>
> <xsl:value-of select="./text()"/>
> </TD></TR>
> </xsl:for-each>
> </TABLE>
> </xsl:template>
> </xsl:stylesheet>
>
>
>
> The associated xml is:
> <?xml version="1.0"?>
> <xslTutorial >
> <chapter>First Chapter</chapter>
> <chapter>Second Chapter
> <chapter>Subchapter 1</chapter>
> <chapter>Subchapter 2</chapter>
> </chapter>
> <chapter>Third Chapter
> <chapter>Subchapter A</chapter>
> <chapter>Subchapter B
> <chapter>sub a</chapter>
> <chapter>sub b</chapter>
> </chapter>
> <chapter>Subchapter C</chapter>
> </chapter>
> </xslTutorial>
>
>
>
> My html output is:
> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <TABLE BORDER="1">
> <TR>
> <TH>Number</TH>
> <TH>text</TH>
> </TR>
> <TR>
> <TD></TD>
> <TD>First Chapter</TD>
> </TR>
> <TR>
> <TD></TD>
> <TD>Second Chapter
> </TD>
> </TR>
> <TR>
> <TD></TD>
> <TD>Subchapter 1</TD>
> </TR>
> <TR>
> <TD></TD>
> <TD>Subchapter 2</TD>
> </TR>
> <TR>
> <TD></TD>
> <TD>Third Chapter
>
> </TD>
> </TR>
> <TR>
> <TD></TD>
> <TD>Subchapter A</TD>
> </TR>
> <TR>
> <TD></TD>
> <TD>Subchapter B
>
> </TD>
> </TR>
> <TR>
> <TD></TD>
> <TD>sub a</TD>
> </TR>
> <TR>
> <TD></TD>
> <TD>sub b</TD>
> </TR>
> <TR>
> <TD></TD>
> <TD>Subchapter C</TD>
> </TR>
> </TABLE>
>
>
> The desired output (according to the example I got this from) should be:
> <TABLE BORDER="1">
> <TR>
> <TH>Number</TH>
> <TH>text</TH></TR>
> <TR>
> <TD>1</TD>
> <TD>First Chapter</TD></TR>
> <TR>
> <TD>2</TD>
> <TD>Second Chapter
> </TD></TR>
> <TR>
> <TD>1</TD>
> <TD>Subchapter 1</TD></TR>
> <TR>
> <TD>2</TD>
> <TD>Subchapter 2</TD></TR>
> <TR>
> <TD>3</TD>
> <TD>Third Chapter </TD></TR>
> <TR>
> <TD>1</TD>
> <TD>Subchapter A</TD></TR>
> <TR>
> <TD>2</TD>
> <TD>Subchapter B </TD></TR>
> <TR>
> <TD>1</TD>
> <TD>sub a</TD></TR>
> <TR>
> <TD>2</TD>
> <TD>sub b</TD></TR>
> <TR>
> <TD>3</TD>
> <TD>Subchapter
> C</TD></TR></TABLE>
>
>
> As you can see, the output I get does not insert the number. Any help is
> appreciated.
> Thanks
>
> - Jerry
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|