| Subject: Re: [xsl] Current Context and document() From: "J.Pietschmann" <j3322ptm@xxxxxxxx> Date: Fri, 21 Feb 2003 22:23:27 +0100 | 
When iterating through elements in an external document('foo.xml'), how can i access the current node of the internal DOM? I thought current() would work, but apparently not.
<xsl:template match="form"> <xsl:for-each select="document('foo.xml')/root/item">
<xsl:value-of select="."/> <!-- value of foo.xml/root/item[i] -->
<xsl:value-of select="current()/@name"/> <!-- attribute of the matched form element ?? -->
</xsl:for-each> </xsl:template>
Current() returns the context node from the context outside the XPath expression, in your case the current node from the document('foo.xml')/root/item node set, or the same as ".". You can store the node you want to keep in a variable:
 <xsl:template match="form">
   <xsl:variable name="current" select="."/>
   <xsl:for-each select="document('foo.xml')/root/item">
      <xsl:value-of select="$current/@name"/>
   </xsl:for-each>
 </xsl:template>| Current Thread | 
|---|
| 
 | 
| <- Previous | Index | Next -> | 
|---|---|---|
| [xsl] Current Context and document(, Marty McKeever | Thread | [xsl] Re: nagging problem embedding, Jesse Ephraim | 
| RE: [xsl] Current Context and docum, Dion Houston | Date | Re: [xsl] XMLPipe model: should we , Mike Brown | 
| Month |