Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSL problems

Status
Not open for further replies.

icross

Programmer
Joined
Jun 25, 2004
Messages
2
Location
US
I am a complete noob with XML and XSLT. And I have a major project to finish with it. Anyway here is my issue:

I am trying to transform an XML document using XSL. I have nodes nested within nodes, and I need to loop through some of these nodes.

the xsl stops working at these line and picks up again later on:

<xsl:for-each select="/propertyAvailListResponse/propertyList/property/address/addressLineList">
<li><xsl:value-of select="address/addressLineList/addressLine"/></li>

I can force the display of this element but it repeats too many times and only shows the value of one element in one node for all nodes...

Any ideas?
 
Difficult to tell, as you didn't post an xml-snippet, but I guess: that you gat the x-path in the <xsl:value-of> wrong, as it reapeats tags also in the x-path of your <xsl:for-each>

The idea would be:
<xsl:for-each select="A/B/C">
<xsl:value-of select ="D/E"/>
</xsl:for-each>
 
jel said it best. To know what the context node is, you need to read the xpath from right to left. This will tell you what the context node is and according to:

<xsl:for-each select="/propertyAvailListResponse/propertyList/property/address/addressLineList">

Your current context node in the for-each loop is the addressLineList node. So any code within the for-each is dealing directly with the addressLineList element/node.

Therefore you do not need to include: address/addressLineList in your value-of because you are already in the addressLineList within this for loop.

<li><xsl:value-of select="addressLine"/></li>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top