• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 6995
  • Last Modified:

XSL Loop and incrementing variable

We are using Oracle XML Publisher to generate PDF formatted Purchase Order Reports. We have tried Oracle Support, but haven't got anywhere, hence trying here...

As part of this work, we have hit a problem.

Part of the XML contains the following data:

        <TEXT> Telephone Number=6955_1 </TEXT>
        <TEXT> Telephone Number=6955_2 </TEXT>
        <TEXT>Telephone Number=6955_3</TEXT>

What we want to do is to loop through the values in the <LINE_ATTACHMENTS> tag, and output the Text Value.

If we try the following snippet:


Then when we view the output, the XSL will always display the value of the 3rd iteration of the <TEXT> tag.

That's okay - but we don't want to hard code the [3] value. We want instead for the number there to be the row count that is currently being used.

We have tried this:


But a long error message was returned.

Basically, we want to increment a variable for each loop through the data, and output the value of that incremented variable in the square brackets as detailed above.

Can this be done?

  • 3
  • 2
1 Solution
Geert BormansInformation ArchitectCommented:
ste_89Author Commented:
It just returns the last value when I try that (Telephone Number=6955_3<)

what I would like to do is display each one. Thanks.
Geert BormansInformation ArchitectCommented:
In XSLT I would do something like this

<xsl:for-each select="/PO_DATA/LINE_ATTACHMENTS/TEXT"/>

but I don't know how to do that in the Oracle syntax


Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

ste_89Author Commented:
Thanks Geert,

I found this by debugging an Oracle document. I've got to try and figure out how to get it into the RTF doc that XML publisher uses. Failing that, I will have to just modifiy the XSL that template builder produces.
Can you see what's going on here?


- <xsl:for-each select="$LINE_LONG_ATTACHMENTS_ROOT_OBJ">
- <xsl:if test="$lineID = .">
  <xsl:variable name="line" select="position()" />
  <xsl:value-of select="../TEXT[$line]" />
  <fo:block />
If you could show where the variables $line, and $LINE_LONG_ATTACHMENTS_ROOT_OBJ, and $lineID are declared it would help.

change this line from:
<xsl:value-of select="../TEXT[$line]" />

<xsl:for-each select="../TEXT">
<xsl:value-of select="."/>
ste_89Author Commented:
Thanks jkmyoung....it did the trick.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now