[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Using of keys with streaming
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. 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:1 14) 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(PatternWithPredica te.java:141) at net.sf.saxon.pattern.PatternWithPredicate.matches(PatternWithPredicate.java:1 33)
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|