[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
strawks wrote:
You cannot do it like this, as XSLTProc is saying: it is a syntax error (after the double colon should be a node name (QName) not a variable name). Instead, if you want to check the name of an attribute and then select that attribute, try this:
select="/document/styles/style[@name=$style_name]/@*[name() = $property]"
If there are more <style> nodes with an attribute "name" with the value of $style_name, this may return more than one attribute, depending on the XSLT version. If you need to do something for each <style>, use templates instead of an absolute XPath.
Re: [xsl] Select attribute using a variable
Subject: Re: [xsl] Select attribute using a variable From: Abel Braaksma <abel.online@xxxxxxxxx> Date: Wed, 23 Jan 2008 11:10:19 +0100 |
strawks wrote:
I have a variable named property and I want to select an attribute using this variable.
Basically :
<xsl:value-of
select="/document/styles/style[@name=$style_name]/attribute::$property"/>
You cannot do it like this, as XSLTProc is saying: it is a syntax error (after the double colon should be a node name (QName) not a variable name). Instead, if you want to check the name of an attribute and then select that attribute, try this:
select="/document/styles/style[@name=$style_name]/@*[name() = $property]"
If there are more <style> nodes with an attribute "name" with the value of $style_name, this may return more than one attribute, depending on the XSLT version. If you need to do something for each <style>, use templates instead of an absolute XPath.
HTH Cheers, -- Abel Braaksma
Current Thread |
---|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Select attribute using a vari, strawks | Thread | Re: [xsl] Select attribute using a , strawks |
[xsl] Select attribute using a vari, strawks | Date | Re: [xsl] Select attribute using a , strawks |
Month |
Keywords