|
Subject: Re: [xsl] Using variables in xpath attribute matches From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx> Date: Fri, 22 Aug 2008 10:20:55 +0100 |
2008/8/21 Martin Honnen <Martin.Honnen@xxxxxx>:
> Matt Lee wrote:
>
>> <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.
>
> All you can do is
> <xsl:value-of select="@*[local-name() = $attribute]"/>
>
But why would you want to? You really don't need to separate out
getting an attributes value...
Why do:
<xsl:call-template name="getAttribute">
<xsl:with-param name="'someAtt'"/>
</xsl:call-template>
instead of:
<xsl:value-of select="@someAtt"/>
?
Remember one of the golden rules for people learning XSLT - don't use
named templates!
One of the worst sins of XSLT is not understanding the recursive
descent processing model (apply-templates and template matching) and
instead just using named templates passing around the context as
param:
<xsl:call-template name="handleSomeElem">
<xsl:with-param select="$current/elem"/>
...
and
<xsl:template name="handleSomeElem">
<xsl:param name="elem">
...
It becomes a maintenance nightmare!
--
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Using variables in xpath , Martin Honnen | Thread | Re: [xsl] Using variables in xpath , Mukul Gandhi |
| Re: [xsl] XSL If Statement, Mandar Jagtap | Date | Re: [xsl] Using variables in xpath , Mukul Gandhi |
| Month |