xsl-list
[Top] [All Lists]

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

2011-11-04 20:28:02
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(_at_)CraneSoftwrights(_dot_)com
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal


--~------------------------------------------------------------------
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>
--~--