Kevin Flynn wrote:
> The new XPath functionality is great! I have a question regarding its usage
> (from the CSS extension):
>
> In certain circumstances, I would like to be able to access an element with
> an attribute that has the same value as one of the current element's
> attributes. The two attributes have the same name, and neither is an ID
> attribute, so I can't use the id() function.
>
> For example:
>
> xpath("//local-config/char-var-d...@name=@name]")
>
> where the second "@name" refers to the current element's name attribute.
>
> In XSL I can do this by declaring a variable "$name" that points to the
> current element's name attribute, and then do:
>
> //local-config/char-var-d...@name=$name]
>
> I don't seem to be having much luck so far:
>
> xpath("//local-config/char-var-d...@name=@name]")
>
> and
>
> xpath("//local-config/char-var-d...@name=./@name]")
>
> both return the first //local-config/char-var-def in the document. I also
> tried
>
> xpath("//local-config/char-var-d...@name=attr(name)]")
>
> but that returned a syntax error as expected.
>
> Is there a way to do what I want?
Sure: xpath("//local-config/char-var-d...@name = current()/@name)]")
I'm sorry I forgot to write in the documentation that standard XSLT
function current() was supported too.