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

[xsl] Numbering of titles


Subject: [xsl] Numbering of titles
From: drkm <darkman_spam@xxxxxxxx>
Date: Sat, 10 Dec 2005 16:51:28 +0100 (CET)

  Hi

  I have a problem regarding the numbering of titles, where
some titles are conditionals.  Basically, I'd like to number
the following titles from 1 to 2 or from 1 to 3 (if the
second title is outputed or not):

    <!-- 1 -->
    <xsl:value-of select="format-number(...)"/>
    <xsl:text>Title.</xsl:text>
    <xsl:if test="...">
      <!-- 2 -->
      <xsl:value-of select="format-number(...)"/>
      <xsl:text>Title.</xsl:text>
    </xsl:if>
    <!-- 2 or 3 -->
    <xsl:value-of select="format-number(...)"/>
    <xsl:text>Title.</xsl:text>

  Indeed, it's a bit more complicated.  I can't record the
result of the test in a variable and use it again to decide
in the last title which number to use.

  To give you the big picture, the XSLT script is generated
from a document like the following.  The 'counter' attribute
is introduced to link together element that are part of the
same logical chain, and the 'counter' element to get the
value of the counter at this point (it can have a 'which'
attribute to get the name of the counter to use).

    <title>
      <text>Title not numbered</text>
    </title>

    <title counter="my.cnt">
      <text>Title #</text>
      <counter/>
    </title>

    <if test="...">
      <title counter="my.cnt">
        <text>Title #</text>
        <counter/>
      </title>
    </if>

    <title counter="my.cnt">
      <text>Title #</text>
      <counter/>
    </title>

  This document is transformed in a XSLT script, with the
'@test' copied verbatim (the point is that the test is
dependant of the source document of the generated XSLT, and
can't be resolved in the first transformation).  This script
is applied to the source document to obtain either:

    Title not numbered
    Title #1
    Title #2
    Title #3

or:

    Title not numbered
    Title #1
    Title #2

depending of the result of the '@test' for a particular
source document.

  Indeed, there can be any number of titles, any number of
tests (with 'if', or 'choose/when', etc.).  They are even
loops, but it's not so important to be able to use 'counter'
within loops.

  I wonder if such a thing is possible with the stateless
nature of XSLT?

  Regards,

--drkm



















	

	
		
___________________________________________________________________________ 
Appel audio GRATUIT partout dans le monde avec le nouveau Yahoo! Messenger 
Tilichargez cette version sur http://fr.messenger.yahoo.com


Current Thread
  • [xsl] Numbering of titles
    • drkm - Sat, 10 Dec 2005 16:51:28 +0100 (CET) <=
      • drkm - Sat, 10 Dec 2005 19:23:42 +0100 (CET)
      • <Possible follow-ups>
      • drkm - Sat, 10 Dec 2005 20:04:19 +0100 (CET)
Keywords