[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Locating an attribute and its value indirectly

Subject: Re: [xsl] Locating an attribute and its value indirectly
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Fri, 04 Nov 2011 21:27:25 -0400

At 2011-11-04 17:05 -0700, Mark wrote:
That works. I think I get it.

Did my " <xsl:value-of select="../Formats/@*[name(.)=@text-location]"/>"try to find @text-location in the <Formats> element?

Yes, because expressions in the predicate are evaluated against that node that was selected in the step.

And your "<xsl:value-of select="../Formats/@*[name(.)=current()/@text-location]"/>" switched the path back to the current context where @text-location actually resides?

The current() function returns that node that was current at the beginning of the evaluation of the XPath expression.

Which, in your case, is the context where @text-location resides, thus Brandon's current()/@text-location works.

In other situations you may find yourself walking from that place to find another node, as in current()/../@idref

I didn't want you to think current() was magic in knowing where @text-location was, it was just coincidentally attached to the element that was current at the beginning of the XPath expression evaluation.

I hope this is helpful.

. . . . . . . . . . Ken

Contact us for world-wide XML consulting and instructor-led training
Free 5-hour video lecture: XSLT/XPath 1.0 & 2.0 http://ude.my/t37DVX
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/s/
G. Ken Holman                   mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal

Current Thread