• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XSLT for each related

 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,

I am iterating below XML using for each loop.

<Test>
<Fab>1</Fab>
<Priority>Test1</Priority>
</Test>
<Test>
<Fab>2</Fab>
<Priority>Test2</Priority>
</Test>



XSLT code:-
<xsl:for-each select="Test">
<tr>
<td><xsl:value-of select="Fab" /></td>
<td ><xsl:value-of select="Priority" /></td>
</tr>
</xsl:for-each>



This XSLT is giving correct output to me.

But Can I get get the same output for below xml.

<Test>
<Fab>1</Fab>
<Priority>Test1</Priority>

<Fab>2</Fab>
<Priority>Test2</Priority>
</Test>

can we iterate this xml for "Fab" and "Priority" value in xslt.
and if yes what would be the code changes for that.






 
Ranch Hand
Posts: 734
7
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Like this.

This suppose each Fab is necessarily followed with a Priority. In the "general" case where the latter might be absent, there you should expect a mis-alignement of data. I leave it to you to elaborate to gard against this possibility which might not be necessary for your special case.
 
reply
    Bookmark Topic Watch Topic
  • New Topic