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

Re: [xsl] Incremental Numbering


Subject: Re: [xsl] Incremental Numbering
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 09 May 2006 21:04:15 +0200

At 2006-05-09 19:00 +0100, Mark Williams wrote:
I've googled and searched the archives and from what I have understood
(which is little), it seems that what I want to do may not be possible.
Hopefully I have misunderstood and someone is able to help.

I don't think you've misunderstood, and I'm sure the archives have been quite clear about the inability to change the values of bound variables.


it constructs an xml file which is then passed for rendering together with
the necessary xsl.

Can you give an example of the XML? Just talking about it in loose terms makes it impossible to give you a sample coded solution.


<if test="option1=1">

So, is option1 a child element of some wrapper?


Do you have:

  <options>
    <option1>1</option1>
    <option2>0</option2>
    <option3>1</option3>
    <option4>0</option4>
  </options>

?

Then you need something like:

<xsl:if test="option1=1">
  <fo:table-row>
    <fo:table-cell>
      <fo:block>1</fo:block>
    </fo:table-cell>
    <fo:table-cell>
      <fo:block>1</fo:block>
    </fo:table-cell
  </fo:table-row>
</xsl:if>
<xsl:if test="option2=1">
  <fo:table-row>
    <fo:table-cell>
      <fo:block>
        <xsl:value-of select="count(option1[.=1])+1"/>
      </fo:block>
    </fo:table-cell>
    <fo:table-cell>
      <fo:block>1</fo:block>
    </fo:table-cell
  </fo:table-row>
</xsl:if>
<xsl:if test="option3=1">
  <fo:table-row>
    <fo:table-cell>
      <fo:block>
        <xsl:value-of select="count(option1[.=1]|option2[.=1])+1"/>
      </fo:block>
    </fo:table-cell>
    <fo:table-cell>
      <fo:block>1</fo:block>
    </fo:table-cell
  </fo:table-row>
</xsl:if>
<xsl:if test="option4=1">
  <fo:table-row>
    <fo:table-cell>
      <fo:block>
        <xsl:value-of select="count(option1[.=1]|option2[.=1]|
                                    option3[.=1])+1"/>
      </fo:block>
    </fo:table-cell>
    <fo:table-cell>
      <fo:block>1</fo:block>
    </fo:table-cell
  </fo:table-row>
</xsl:if>

This is obviously very rough and I appreciate there is no xsl:increment
function, but it's something like this that I need.

No, you do not need it as you can do what you want declaratively. If you've tried to approach the problem thinking you need only a given technique that is not implemented, then you won't readily think of alternative approaches.


Is there any way I can store and increment a value in this way?

No, but I'm sure from your earlier comment that you've already determined from the archives that this is not possible.


I hope I've made myself clear. Apologies if not.

I hope I've understood your requirement. Apologies if not.


And I hope this helps.

. . . . . . . . . . Ken

--
Registration open for XSLT/XSL-FO training: Wash.,DC 2006-06-12/16
Also for XSLT/XSL-FO training:    Minneapolis, MN 2006-07-31/08-04
Also for XML/XSLT/XSL-FO training:Birmingham,England 2006-05-22/25
Also for XSLT/XSL-FO training:    Copenhagen,Denmark 2006-05-08/11
World-wide on-site corporate, govt. & user group XML/XSL training.
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)
Male Cancer Awareness Aug'05  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


Current Thread
Keywords
xml