Re: building a mental model for the "current node" behavior

"David Carlisle [email protected]" <[email protected]>
Newsgroups gmane.text.xml.xsl.general.mulberrytech
Message-ID <[email protected]>
On Thu, 5 Nov 2020 at 14:46, Martin Honnen [email protected] <
[email protected]> wrote:

> Am 05.11.2020 um 15:11 schrieb Chris Papademetrious
> [email protected]:
> > 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 “.”?
>
> The dot is used or usable in any XPath expression
> (https://www.w3.org/TR/xpath-31/#dt-dynamic-context) so I would suggest
> to rather look at XPath to understand the context item or context node
> as otherwise stuff like
>     /items/item[cat[. = /categories/cat]]
> will not be understood.
>
>
> > 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?
>
> That is what the
>    current()
> function does, I am currently not sure why you first cite it and then
> seem to ask for another function doing the job of the current() function.
>
>
No Christopher was correct, there is no function that does what he asks,
and you need to use a variable.
current() is the  node at the beginning of the xpath not the surrounding
template.

Given

<xsl:template match="wibble">

<xsl:for-each select=".//zzz">

<xsl:value-of select=" something with current()"/>



then current() is the zzz node, and wibble is not accessible unless you
saved it in a variable before the for-each.

David
--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/3329386
or by email: [email protected]
--~--
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.