[thelist] XSLT Attributes and Variable name

David.Cantrell at Gunter.AF.mil David.Cantrell at Gunter.AF.mil
Wed Jan 15 14:08:13 CST 2003


>Where @refname in the <a> tag will evaluate to the top-level variable
>created earlier, such that the refname attribute of the <reference> tag
>is replaced by the value of the variable with the corresponding name
>attribute.

I agree with Howard, you need to post a more complete code example showing
the structure of the XML document as well as what you are trying to
accomplish with the XSLT document.

First, your variable cannot have an "@" sign in front of it. That symbol is
reserved for attributes. And you reference the variable with a "$", i.e.
"$id" instead of "@id".

Also since your question is hard to decipher, maybe it's that you are trying
to do something completely different than the way you should actually do it
in XML? If you post more code we can give more insight.

To be honest it looks like you are trying really, really hard to do
something simple, when the documentation should tell you exactly how to do
what you want without you needing to go through all of this trouble. :)

Your id variable is scoped into the template in which it is created, it
cannot propagate downward the way you want. You can create a global
variable, however variables in XSLT are not "true" variables, rather they
are more like write-once constants -- once written they cannot change their
value. If you place the variable within a template and then use
apply-templates to call another template, you can pass the variable as a
parameter. Look in your documentation for <xsl:param> and <xsl:with-param>
for examples and documentation.

One more thing: when binding your variable, do it like this:  <xsl:variable
name="id" select="@refuri"/>

Don't ask, it'll make my head hurt just trying to explain it to you. :)

-dave



More information about the thelist mailing list