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?
Created May 4, 2012
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>