In XSL, an xsl:for-each statement sets a context based on the select attribute of that statement. Once you're within that context, how can you access elements higher up the tree?

Peter Ciuffetti

All you need to do is start the pattern with slash. E.g.

<result>
<xsl:for-each select="body/item">
<item>
	<xsl:attribute name="attrib">
		<xsl:value-of select="/document/@attrib"/>
	</xsl:attribute>
	<xsl:value-of select="."/>
</item>
</xsl:for-each>
</result>
Will produce
<result>
  <item attrib="foo">1</item>
  <item attrib="foo">2</item>
  <item attrib="foo">3</item>
</result>
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact