-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
Hi,
For my XSLT 2 processor, https://github.com/egh/xjslt, I would like to fix the implementation of last() and position(). The behavior is a little tricky, though.
For instance, this stylesheet:
<?xml version="1.0" encoding="UTF-8" ?>
<t:transform xmlns:t="http://www.w3.org/1999/XSL/Transform" version="2.0">
<t:template match="/">
<out>
<t:for-each select="/doc/foo">
<t:value-of select="position()"/>
</t:for-each>
</out>
</t:template>
</t:transform>
when applied to:
<?xml version="1.0" encoding="UTF-8"?>
<doc>
<foo/><bar/>
<foo/><bar/>
<foo/><bar/>
</doc>
should output:
<?xml version="1.0" encoding="UTF-8"?><out>123</out>
In contrast, for instance, the stylesheet:
...
<t:for-each select="/doc/element()">
<t:if test="local-name() = 'foo'">
<t:value-of select="position()"/>
</t:if>
</t:for-each>
would output 135. In other words, the position() (and last()) depend on the for-each xpath and what was selected there.
In order to do this with my implementation, I need to either be able:
- to pass in something to
evaluateXPath*functions to override thedynamicContext.contextSequence, or - to override the
position()andlast()functions in some cases, i.e. when thecontextItemis the same as thecontextNodeI passed in (and so I can calculate these values based on the node set being processed). But this means both:
a. I need access to thecontextItemand:
b. Ideally, I need to pass computation to the built in implementation if thecontextItemis not thecontextNodeI passed in. - something else that I haven't thought of?
(1) is probably the easiest solution from my point of view, but I don't know if this is feasible.
I am happy to implement a solution to this, but I wanted to get a sense of what the best solution might be.
Thank you for your help! Let me know what other info might help you.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels