RE: [xsl] in-document references

Subject: RE: [xsl] in-document references
From: "Michael Kay" <michael.h.kay@xxxxxxxxxxxx>
Date: Wed, 8 Jan 2003 11:10:42 -0000
> What I want to do is to locate the appropriate "define" node-set, and 
> have XSLT pretend that the "define" nodeset is in the place of the 
> "ref" node. Right now I am using <xsl:apply-templates> to apply the 
> templates to the "define" nodeset. But that's not good 
> enough, because 
> I'd like to be able to treat the anscestors of the "ref" node as the 
> ancestors of the "define" nodeset. That would make my 
> programming a lot 
> easier.
> 
> How do I do that?

You're making things much more difficult than they are. Perhaps you have
overlooked that a path expression can start with a variable reference:

<xsl:apply-templates select="define">
  <xsl:with-param name="ref" select="ref"/>
</xsl:apply-templates>

<xsl:template match="define">
  <xsl:param name="ref"/>
  <xsl:value-of select="$ref/ancestor::foo/@bar"/>
</xsl:template>

Michael Kay
Software AG
home: Michael.H.Kay@xxxxxxxxxxxx
work: Michael.Kay@xxxxxxxxxxxxxx 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread