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

RE: Annoying problem


Subject: RE: Annoying problem
From: Mark Hayes <mark@xxxxxxxxxxx>
Date: Tue, 23 Nov 1999 20:36:30 -0800

<xsl:number> was made for this.  

>From this source:

<section>
  <section>
    <section/>
    <section/>
  </section>
  <section>
    <section/>
    <section/>
  </section>
</section>

This stylesheet:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
  <xsl:template match="/">
    <xsl:apply-templates/>
  </xsl:template>
  <xsl:template match="section">
    <section>
      <xsl:number level="multiple" format="1.1"/>
      <xsl:apply-templates/>
    </section>
  </xsl:template>
</xsl:stylesheet>

Produces this output:

<?xml version="1.0" encoding="utf-8"?>
<section>1
  <section>1.1
    <section>1.1.1</section>
    <section>1.1.2</section>
  </section>
  <section>1.2
    <section>1.2.1</section>
    <section>1.2.2</section>
  </section>
</section>

--
mark

> -----Original Message-----
> From: disco [mailto:disco@xxxxxxxxxxxxxxx]
> Sent: Tuesday, November 23, 1999 7:05 PM
> To: xsl-list@xxxxxxxxxxxxxxxx
> Subject: Annoying problem
> 
> 
> Hi,
> 
> This is an annoying problem which will hopefully be less 
> annoying to those
> of you who haven't been banging your heads against it for the past few
> hours:
> 
> I'm writing a transformation for my thesis, from XML to HTML. 
> Part of the
> DTD states that sections may nest recursively within 
> sections. Given any
> one of these sections or subsections as a context node, I'd like to be
> able to generate a "tumbler" for that node. For example:
> 
> <section> <!-- 1 -->
>  <section> <!-- 1.1 --> </section>
>  <section> <!-- 1.2 -->
>   <section> <!-- 1.2.1 --> </section>
>   <section> <!-- 1.2.2 --> </section>
>  </section>
>  <section> <!-- 1.3 --> </section>
> </section>
> <section> <!-- 2 --> </section>
> 
> I have been trying a lisp-style approach: given a "section" 
> node, find its
> position relative to its section siblings, and concatenate 
> that value (as
> a string) with that of its parent, and so forth until the parent is no
> longer a section node. While I'm fairly convinced this is the correct
> approach, I haven't been able to get it to work. I'd say I know XSLT
> and XPath fairly well but many intricacies of the languages 
> are still new
> to me, so this is somewhat aggravating...
> 
> Any help or ideas would be much appreciated.
> 
> Thanks,
> Dan
> 
> 
>  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
  • Annoying problem
    • disco - Tue, 23 Nov 1999 22:04:51 -0500 (EST)
      • <Possible follow-ups>
      • Mark Hayes - Tue, 23 Nov 1999 20:36:30 -0800 <=
Keywords