RE: [xsl] Incremental Numbering

Subject: RE: [xsl] Incremental Numbering
From: "Mark Williams" <mark@xxxxxxxxxxxxxxxxx>
Date: Wed, 10 May 2006 09:12:18 +0100
Hi Ken,

Thanks for the answer and thanks to all that have answered.

There could be a large number of options potentially so I'm keen to
avoid a solution that has to input every possible option.

I think what I need to do is structure the XML returned from html page
so that it groups all options with a value of 1 together. I can then
just use count and position.

Sorry to all if I didn't make what I was trying to do clear.


Mark Williams

________________________________

GWSmartmove

24 St Andrews Crescent, Cardiff, CF10 3DD

E: enquiries@xxxxxxxxxxxxxxxxx
T: 02920375901
F: 02920375909

www.gwsmartmove.co.uk

The contents of this email and any attachments are the property of
Gimblett Williams Solicitors Limited and are intended for the
confidential use of the named recipient(s) only. If they have been
received by you in error please maintain confidentiality, notify us,
destroy copies and delete them from your computer. It is the
responsibility of the recipient to scan this email for viruses.


-----Original Message-----
From: G. Ken Holman [mailto:gkholman@xxxxxxxxxxxxxxxxxxxx]
Sent: 09 May 2006 20:04
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] Incremental Numbering

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