xsl-list
[Top] [All Lists]

Numbering of titles

2005-12-10 08:51:28
  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 
Téléchargez cette version sur http://fr.messenger.yahoo.com

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>