Subject: Re: [xsl] Using variables in xpath attribute matches From: "Darcy Parker" <darcyparker@xxxxxxxxx> Date: Thu, 21 Aug 2008 13:38:36 -0400 |
If you are using Saxon, I believe a solution exists by using the extension functions saxon:expression() and saxon:eval(). See: http://www.saxonica.com/documentation/extensions/functions/expression.html http://www.saxonica.com/documentation/extensions/functions/eval.html Darcy On Thu, Aug 21, 2008 at 1:07 PM, Matt Lee <reachmatt.lee@xxxxxxxxx> wrote: > > Hi, > > I have the following template: > > <xsl:template name="get_attribute"> > <xsl:param name="attribute"/> > <xsl:value-of select="@<<FIXME>>"/> > </xsl:template> > > > I would like to use the value of the attribute parameter passed into > this template as the attribute match expression in the inner most > select. But I am quite confused as to what the syntax is for doing > this. For instance, given this XML, > > <foo> > <node attrib1="1" attrib2="2"/> > </foo> > > I would like to invoke the get_attribute template as follows: > > <xsl:call-template name="get_attribute"> <xsl:with-param > name="attribute>attrib1</xsl:with-param> > <xsl:call-template name="get_attribute"> <xsl:with-param > name="attribute>attrib2</xsl:with-param> > > I have tried the following syntaxes, with no success. The parser gives > syntax errors. > > <xsl:value-of select="@$attribute"/> > <xsl:value-of select="@{$attribute}"/> > <xsl:value-of select="@'$attribute'"/> > <xsl:value-of select="@string($attribute)"/> > > Everything works fine, if I directly key in the attribute name: > > <xsl:value-of select="@attrib1"/> and so on. > > Am I trying to do something really stupid? Please advise. It sounds > like it would be useful to construct the xpath expression via > variables. > > matt
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Using variables in xpath , Mukul Gandhi | Thread | Re: [xsl] Using variables in xpath , David Carlisle |
Re: [xsl] Using variables in xpath , Martin Honnen | Date | [xsl] XSL If Statement, sumit patki |
Month |