RE: [xsl] can I give xsl:number a starting position?

Subject: RE: [xsl] can I give xsl:number a starting position?
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Wed, 4 Sep 2002 09:33:28 +0100
I think you will have to do something along the lines of:

<xsl:number
value="count(ancestor::chapter/preceding-sibling::chapter)+$start-chapte
r"
format="1"/>
<xsl:text>.</xsl:text>
<xsl:number value="count(ancestor::h1/preceding-sibling::h1)+$start-h1"
format="1"/>
<xsl:text>.</xsl:text>
<xsl:number value="count(ancestor::h2/preceding-sibling::h2)+$start-h2"
format="A"/>

etc.

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Jeff Rosler
> Sent: 04 September 2002 02:56
> To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] can I give xsl:number a starting position?
> 
> 
> Hi All,
> 
> I would like to use xsl:number to handle section numbering in 
> my document, but I need to tell it a section number to start 
> with (i.e. not 1). Can someone tell me if there is an easy 
> way to do this? I was trying the following -
> 
> <xsl:number count="chapter|h1|h2|h3|h4" format="1.1.A.1.A" 
> level="multiple"/>
> 
> This works fine, but always starts at 1.1.A.1.A. I tried 
> setting format to the section that I want it to start, but 
> that didn't work. At the moment, I'm thinking that I'll need 
> to write some convoluted code using
> position() for each section number, but I thought I'd try and 
> post this and see if anyone else has solved this problem 
> before reinventing the wheel :-).
> 
> Basically, my problem is that I have an XML document that's 
> been chunked up into smaller pieces. I need to convert each 
> of those pieces to HTML separately, with the correct section 
> numbers. In my case, I am doing this by running some Java 
> code that uses JAXP to call the transform (and set a 
> parameter for the XSL with the correct starting section 
> number). My thinking is that I can use the param in my XSL as 
> a starting position to xsl:number (maybe something like the 
> following) -
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
>   xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
>   xmlns="http://www.w3.org/1999/xhtml";
> >
> <xsl:output indent="yes" method="html" 
> omit-xml-declaration="no" encoding="ISO-8859-1"
>   doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
>  
> doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transit
> ional.dtd"
> />
> 
> <xsl:param name="starting_section" />
> 
> ...
> 
> <xsl:number count="chapter|h1|h2|h3|h4" 
> format="$starting_section" level="multiple"/>
> 
> ...
> 
> However, since I can't get it to work with a hard coded 
> value, I haven't added the code for the starting_section param
> 
> Thanks for any and all feedback,
> 
> Jeff Rosler
> Consultant
> Flatirons Solutions Corp
> 2555 55th Street
> Suite 100D
> Boulder, CO  80301
> 303-544-0514 x11
> jeff.rosler@xxxxxxxxxxxxxxxxxxxxxx
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


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


Current Thread