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

Re: [xsl] How do I set up a counter or sequence number variable


Subject: Re: [xsl] How do I set up a counter or sequence number variable
From: "G. Ken Holman g.ken.holman@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 3 Nov 2014 20:33:46 -0000

At 2014-11-03 19:48 +0000, Catherine Wilbur cwilbur@xxxxxxxxxxx wrote:
Looked on the archive and did not see anything similar to what I am doing.

Because what you are doing is not allowed, as you are thinking of XSLT in terms of other programming languages that do not work the same way.


I am trying to put a sequence number for each output line. Each time I output a line I want to increment the counter by one.

That's the problem. Rather than wanting that, I think what you want to do is reflect the invoice line number since it looks like you are creating an output for each invoice line. There are a couple ways of doing this: if you are processing invoice lines as a group you can use position(), if you are processing items inside of invoice lines you can count which invoice line you are at by using <xsl:number/>:


<xsl:number count="invoice_line"/>

Putting out your entire stylesheet into a help request inhibits getting help because people like me can't take the time to figure out what you are doing. You haven't narrowed down your issue to an XSLT example of a few lines that illustrates the problem you are having.

So if I've guessed incorrectly at what you are trying to do, then my example above is likely wrong, but the principle is correct: XSLT will count the input tree for you, so if you want the output to reflect the ordinal position of information in your input, you don't have to create and maintain a counter, you just have to report that aspect of your input in your output.

I hope this helps. If you would like to listen to a lecture on <xsl:number/> it happens to be available as a free preview in streaming video at:

  http://www.CraneSoftwrights.com/links/ptux-coupon.htm
  (note that I've used a link offering a 60% discount off of the list price)

The free lecture is Module 7 Lesson 2 ... just scroll down the page to find it.

I hope this helps.

. . . . . . Ken


-- Public UBL and code list hands-on classes - Stockholm, Dec. 3&4,2014 | Contact us for world-wide XML consulting and instructor-led training | Free 5-hour lecture: http://www.CraneSoftwrights.com/links/video.htm | Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ | G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx | Google+ profile: http://plus.google.com/+GKenHolman-Crane/about | Legal business disclaimers: http://www.CraneSoftwrights.com/legal |


--- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com


Current Thread
Keywords