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.

<xsl:for-each select="body/item">
	<xsl:attribute name="attrib">
		<xsl:value-of select="/document/@attrib"/>
	<xsl:value-of select="."/>
Will produce
  <item attrib="foo">1</item>
  <item attrib="foo">2</item>
  <item attrib="foo">3</item>