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

Subject: [xsl] building a mental model for the "current node" behavior
From: "Chris Papademetrious christopher.papademetrious@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 5 Nov 2020 14:11:21 -0000
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

Current Thread