Subject: [xsl] Using of keys with streaming From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Sun, 24 Apr 2016 10:27:59 -0000 |
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-s et.xml for any test case mentioning streaming, but there does not seem to be one.
<?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: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>
<?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>
<?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."
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 net.sf.saxon.trans.KeyIndex.buildIndex(KeyIndex.java:91) at net.sf.saxon.trans.KeyManager.buildIndex(KeyManager.java:259)
at net.sf.saxon.expr.FirstItemExpression.evaluateItem(FirstItemExpression.java:1 14)
at net.sf.saxon.expr.IdentityComparison.effectiveBooleanValue(IdentityComparison .java:200)
at net.sf.saxon.pattern.PatternWithPredicate.matchesPredicate(PatternWithPredica te.java:141) at net.sf.saxon.pattern.PatternWithPredicate.matches(PatternWithPredicate.java:1 33)
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 geprC<ft. https://www.avast.com/antivirus
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Namespaces, bad idea or w, Flynn, Peter pflynn@ | Thread | [xsl] Best practice for group-adjac, David Sewell dsewell |
Re: [xsl] Namespaces, bad idea or w, Eliot Kimber ekimber | Date | Re: [xsl] Namespaces, bad idea or w, Flynn, Peter pflynn@ |
Month |