Subject: Re: [xsl] problem with numbering From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Mon, 16 Sep 2002 17:30:04 +0200 |
I have a problem with the xsl:number-element. In the following part of a XML-document I am not able to produce the numbering which I have declared in the comments.
<NUMMERIERUNG> <!--1.--><NELEMENT>text1</NELEMENT> <!--2.--><NELEMENT>text2</NELEMENT> <NUMMERIERUNG> <!--2.1--><NELEMENT>text21</NELEMENT> <!--2.2--><NELEMENT>text22</NELEMENT> </NUMMERIERUNG> <!--3.--><NELEMENT>text3</NELEMENT> </NUMMERIERUNG>
<?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="NELEMENT"> <xsl:for-each select="ancestor::NUMMERIERUNG"> <xsl:if test="position() > 1"> <xsl:value-of select="count(preceding-sibling::NELEMENT)"/> <xsl:text>.</xsl:text> </xsl:if> </xsl:for-each> <xsl:value-of select="count(preceding-sibling::NELEMENT)+1"/> <xsl:text> </xsl:text> <xsl:value-of select="."/> </xsl:template>
T:\ftemp>xt lars.xml lars.xsl <?xml version="1.0" encoding="utf-8"?>
1 text1 2 text2
2.1 text21 2.2 text22
<NUMMERIERUNG> <!--1.--><NELEMENT>text1</NELEMENT> <!--2.--><NELEMENT>text2 <NUMMERIERUNG> <!--2.1--><NELEMENT>text21</NELEMENT> <!--2.2--><NELEMENT>text22</NELEMENT> </NUMMERIERUNG> </NELEMENT> <!--3.--><NELEMENT>text3</NELEMENT> </NUMMERIERUNG>
<?xml version="1.0" encoding="iso-8859-1"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="NELEMENT"> <xsl:number level="multiple"/> <xsl:text> </xsl:text> <xsl:apply-templates/> </xsl:template>
T:\ftemp>xt lars2.xml lars2.xsl <?xml version="1.0" encoding="utf-8"?>
1 text1 2 text2
2.1 text21 2.2 text22
-- Upcoming hands-on in-depth Europe: Sep 18-Sep 20,2002 XSLT/XPath and XSL-FO North America: Sep 30-Oct 4,2002
G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) ISBN 0-13-065196-6 Definitive XSLT and XPath ISBN 0-13-140374-5 Definitive XSL-FO ISBN 1-894049-08-X Practical Transformation Using XSLT and XPath ISBN 1-894049-10-1 Practical Formatting Using XSL-FO Next public training: 2002-09-18,19,30,10-03,12-08,2003-03-04,07
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] problem with numbering, Jeni Tennison | Thread | Re: [xsl] problem with numbering, michael . h . kay |
[no subject], Bryan Tulloch | Date | Re: [xsl] problem with numbering, Jeni Tennison |
Month |