xsl-list
[Top] [All Lists]

Re: Test a node set based on an attribute that will match a variable

2005-01-20 13:01:17
I also have this same need in a few templates... But that returns an error

Variables may not be used within this expression. spec_off/offer[./@*[local-name()=-->$version<--]='true']

syntax: <xsl:template match="spec_off/offer[./@*[local-name()=$version]='true']">...</xsl:template>

Is this just illegal all around, or is there a way to have this work too?

It's not possible to have variable references in match patterns.
You can probably avoid them by doing the test when you call the template, rather than in the match pattern.

e.g.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
        
<xsl:variable name="version">CO</xsl:variable>

<xsl:template match="spec_off">
<xsl:apply-templates select="*[(_at_)*[local-name()=$version]='true']"/>
</xsl:template>

<xsl:template match="spec_off/*">
<xsl:text/>I'm an '<xsl:value-of select="local-name()"/>' node with a true '<xsl:value-of select="$version"/>' attribute.
</xsl:template>

</xsl:stylesheet>


regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-view.cgi?userid=38041)
Spread the wiki (http://www.wikipedia.org)

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--