xsl-list
[Top] [All Lists]

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

2020-11-05 16:04:32
On 05.11.2020 22:13, David Carlisle 
d(_dot_)p(_dot_)carlisle(_at_)gmail(_dot_)com wrote:


On Thu, 5 Nov 2020 at 14:46, Martin Honnen martin(_dot_)honnen(_at_)gmx(_dot_)de
<mailto:martin(_dot_)honnen(_at_)gmx(_dot_)de> 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com
<mailto:xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com>> wrote:

    Am 05.11.2020 um 15:11 schrieb Chris Papademetrious
    christopher(_dot_)papademetrious(_at_)synopsys(_dot_)com
    <mailto:christopher(_dot_)papademetrious(_at_)synopsys(_dot_)com>:

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

That's true, guess my only excuse is that I did eliminate pull
processing from my mental model long before Gerrit punished it with his
score :)
--~----------------------------------------------------------------
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>