xsl-list
[Top] [All Lists]

[xsl] building a mental model for the "current node" behavior

2020-11-05 08:11:34
I'm trying to better my understanding of "current node" behavior in XSLT, and I 
have a couple questions.


1. Which stylesheet elements select the current node "."?

"How XPath Context Is Initialized" at

https://www.lenzconsulting.com/how-xslt-works/

states that aside from template matches, only <for-each> (and 
<foreach-in-group>) change the current node ".". However, other XSLT stylesheet 
elements provide a @select attribute:

<xsl:copy select="...">
  ...
</xsl:copy>
<xsl:message select="...">
  ...
</xsl:message>

As a novice, I get confused remembering when the current node does/doesn't 
change. There's also this, which I'm trying to grasp:

https://www.w3.org/TR/xslt-30/#func-current

What's a good mental model for remembering this?


2. Inside an <xsl:template> block, is there a function that returns the current 
*template-matched* node?

For example, let's say I'm looping through the contents of a variable and I 
want to <xsl:copy> my current template node in each iteration. Is there a 
function to reference it without having to stuff it in a variable at the 
beginning of the template? I don't see such a function in the spec, but it 
could be eluding me.


Thanks!

-----
Chris Papademetrious
Tech Writer, Implementation Group
(610) 628-9718 home office
(570) 460-6078 cell
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--
<Prev in Thread] Current Thread [Next in Thread>