[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

XSL Loop and incrementing variable

Posted on 2007-03-29
6
Medium Priority
?
6,984 Views
Last Modified: 2013-12-12
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:


<PO_DATA>
    <LINE_ATTACHMENTS>
        <TEXT> Telephone Number=6955_1 </TEXT>
        <ID>765923</ID>
        <TEXT> Telephone Number=6955_2 </TEXT>
        <ID>765924</ID>
        <TEXT>Telephone Number=6955_3</TEXT>
        <ID>765925</ID>
    </LINE_ATTACHMENTS>
</PO_DATA>


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:


<?/PO_DATA/LINE_ATTACHMENTS/TEXT[3]?>


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:


<?/PO_DATA/LINE_ATTACHMENTS/TEXT["row:position()]?>


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?

Thanks
0
Comment
Question by:ste_89
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 18814821
try
<?/PO_DATA/LINE_ATTACHMENTS/TEXT[position()=last()]?>
0
 

Author Comment

by:ste_89
ID: 18814837
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.
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 18814885
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

cheers

Geert
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:ste_89
ID: 18815042
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?

Cheers,


- <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 />
  </xsl:if>
  </xsl:for-each>
0
 
LVL 12

Accepted Solution

by:
jkmyoung earned 1000 total points
ID: 18823999
If you could show where the variables $line, and $LINE_LONG_ATTACHMENTS_ROOT_OBJ, and $lineID are declared it would help.

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

to:
<xsl:for-each select="../TEXT">
<xsl:value-of select="."/>
</xsl:for-each>
0
 

Author Comment

by:ste_89
ID: 18836115
Thanks jkmyoung....it did the trick.
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question