xsl-list
[Top] [All Lists]

[xsl] Using of keys with streaming

2016-04-24 05:28:05

I was wondering whether a key can be used with streaming in XSLT 3.0 so
I tried an example, the result is that Saxon 9.7 gives a run-time error
while Exselt compiles and runs the example fine.

To be a bit more systematic, I searched
https://dvcs.w3.org/hg/xslt30-test/file/07ce9cc5b7f6/tests/fn/key/_key-test-set.xml
for any test case mentioning streaming, but there does not seem to be one.

The test case I wrote is

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
        xmlns:xs="http://www.w3.org/2001/XMLSchema";
        xmlns:math="http://www.w3.org/2005/xpath-functions/math";
        exclude-result-prefixes="xs math"
        version="3.0">

        <xsl:mode streamable="yes" on-no-match="shallow-copy"/>

        <xsl:key name="group" match="item" use="@class"/>

        <xsl:template match="item[. is key('group', @class)[1]]">
                <xsl:copy>
                        <xsl:attribute name="group-head" select="@class"/>
                        <xsl:apply-templates select="@*"/>
                        <xsl:apply-templates/>
                </xsl:copy>
        </xsl:template>
</xsl:stylesheet>

to be run against an input document

<?xml version="1.0" encoding="UTF-8"?>
<root>
        <item class="class1">item 1</item>
        <item class="class2">item 2</item>
        <item class="class1">item 3</item>
        <item class="class1">item 4</item>
        <item class="class3">item 5</item>
        <item class="class2">item 6</item>
</root>

for which Exselt outputs

<?xml version="1.0" encoding="UTF-8"?><root>
        <item group-head="class1" class="class1">item 1</item>
        <item group-head="class2" class="class2">item 2</item>
        <item class="class1">item 3</item>
        <item class="class1">item 4</item>
        <item group-head="class3" class="class3">item 5</item>
        <item class="class2">item 6</item>
</root>

and in its diagnostics explicitly says "[Streaming]  12,  3: The
sequence constructor of the template with pattern 'item[. is
key("group", @class)[1]]' (prec: 041, prio: 0.5) in streamable mode
'#unnamed' has Grounded posture, Motionless sweep and is
guaranteed-streamable."

while Saxon compiles it but gives a run-time error

java.lang.UnsupportedOperationException:
net.sf.saxon.trans.XPathException: Navigation using descendant axis is
not supported from a streamed input node

with the stack trace indicating that the problem is related with the use
of the key call in the pattern:

at com.saxonica.ee.stream.om.FleetingNode.iterateAxis(FleetingNode.java:625)

at net.sf.saxon.pattern.Pattern.selectNodes(Pattern.java:319)

at net.sf.saxon.trans.KeyIndex.constructIndex(KeyIndex.java:128)

at net.sf.saxon.trans.KeyIndex.buildIndex(KeyIndex.java:91)
at net.sf.saxon.trans.KeyManager.buildIndex(KeyManager.java:259)

at net.sf.saxon.trans.KeyManager.obtainSharedIndex(KeyManager.java:386)

at net.sf.saxon.trans.KeyManager.obtainIndex(KeyManager.java:356)

at net.sf.saxon.trans.KeyManager.selectByKey(KeyManager.java:303)

at net.sf.saxon.functions.KeyFn.call(KeyFn.java:252)

at net.sf.saxon.expr.FunctionCall.iterate(FunctionCall.java:546)

at
net.sf.saxon.expr.FirstItemExpression.evaluateItem(FirstItemExpression.java:114)

at net.sf.saxon.expr.IdentityComparison.getNode(IdentityComparison.java:220)

at
net.sf.saxon.expr.IdentityComparison.effectiveBooleanValue(IdentityComparison.java:200)

at
net.sf.saxon.pattern.PatternWithPredicate.matchesPredicate(PatternWithPredicate.java:141)
at
net.sf.saxon.pattern.PatternWithPredicate.matches(PatternWithPredicate.java:133)


I would be surprised if a key (which requires indexing all nodes
matching a certain pattern in a document) would work with streaming but
I guess then the streamability analysis should reject the XSLT.


---
Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft.
https://www.avast.com/antivirus
--~----------------------------------------------------------------
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>
  • [xsl] Using of keys with streaming, Martin Honnen martin(_dot_)honnen(_at_)gmx(_dot_)de <=