Two problems with accumulators and a map trying to collect data
Added by Martin Honnen over 7 years ago
While trying to use accumulators with Saxon 9.8 I have run into two problems:
A stylesheet is assessed as not being streamable with 9.8 EE while 9.7 EE assesses it as streamable, the diagnostic messages that 9.8 gives are contradicting each other¶
That stylesheet, when run without streaming in 9.8 EE gives me the wanted result while with 9.8 HE it outputs nothing¶
A minimum test case I have reproduced that to is as follows, it just tries to collect some information in a map using two accumulators:
A sample input I use for the parameter @notif-uri@ is
1
Message 1
2
Message 2
Now when I try to run it with @Saxon-EE 9.8.0.2J@ from the command line using @-xsl:.\test201706270109.xsl -it@ Saxon complains:
Static error on line 27 column 123 of test201706270109.xsl: XTSE3430: The body of the xsl:stream instruction is not streamable * A call to accumulator-after() is consuming when there are no preceding consuming instructions * There is more than one consuming operand: {xsl:apply-templates} on line 28, and {fn:accumulator-after(...)} on line 29
I think the two sentences ("no preceding consuming instructions", "more than one consuming operand") are contradicting each other and make no sense as far as I can tell, indeed the text and examples in the spec explaining how to use @accumulator-after()@ with streaming explicitly explain that one needs to have an @xsl:apply-templates/@ before the call to the function, as the stylesheet does.
9.7 EE assesses that code as streamable and runs it fine with streaming, giving the expected result @map{1:"Message 1",2:"Message 2"}@ that I also get with 9.8 EE when I set @STREAMABLE=0@ on the command line.
So that is the problem with 9.8 and the above code, the other problem is that somehow @Saxon-HE 9.8.0.2J@ does not give any output for the map at all, when run with @-t@ all I get is
Warning at xsl:mode on line 11 column 119 of test201706270109.xsl: Request for streaming ignored: this Saxon configuration does not support streaming Stylesheet compilation time: 303.089858ms Processing (no source document) initial template = xsl:initial-template Execution time: 10.209321ms Memory used: 39.861.224
so it seems the accumulator(s) fail to build the map with HE.
Replies (5)
Please register to reply
RE: Two problems with accumulators and a map trying to collect data - Added by Michael Kay over 7 years ago
Problem 1 logged here with a preliminary explanation:
RE: Two problems with accumulators and a map trying to collect data - Added by Michael Kay over 7 years ago
Question 1 now resolved.
Regarding question 2, how are you running the transformation?
Because the result of the initial template is a map, it needs to be run with build-tree=false, and it can't be serialized as XML or HTML. To reproduce the problem I therefore need to know how you were running it.
RE: Two problems with accumulators and a map trying to collect data - Added by Martin Honnen over 7 years ago
I run that reduced test case with Saxon 9.8 HE from the command line:
java -jar 'C:\Program Files\Saxonica\Saxon9.8HE\saxon9he.jar' -t -xsl:.\test201706270109.xsl -it
RE: Two problems with accumulators and a map trying to collect data - Added by Martin Honnen over 7 years ago
I have read up on @build-tree@ in the spec and with the @<xsl:output method="adaptive"/>@ it should be false anyway. I have now also tried an explicit @<xsl:output method="adaptive" build-tree="no"/>@ but HE does not output the map.
In the real code I have
and then HE always complains
Static error at xsl:variable on line 22 column 66 of test201706270103.xsl: XTTE0570: An empty sequence is not allowed as the value of variable $id-msg-map
while Saxon EE (when I set the @STREAMABLE@ param as 0) runs and executes the code fine and uses the map in that variable.
I will show the more complex code below, it attempts to collect data from one secondary input document first in a map to then process the primary input document to find matches in the map and replace data:
The primary input is e.g.
DOCATTR.BATCHID
1
DOCATTR.CID
DOCATTR.EMAILCC
DOCATTR.EMAILCCNAME
DOCATTR.EMAILBCC
DOCATTR.SENDERADDRESS
DOCATTR.SENDERNAME
old text 1
DOCATTR.EXPIRATION
DOCATTR.PRIORITYNC
2
DOCATTR.CID
DOCATTR.EMAILCC
DOCATTR.EMAILCCNAME
DOCATTR.EMAILBCC
DOCATTR.SENDERADDRESS
DOCATTR.SENDERNAME
old text 2
DOCATTR.EXPIRATION
DOCATTR.PRIORITYNC
3
DOCATTR.CID
DOCATTR.EMAILCC
DOCATTR.EMAILCCNAME
DOCATTR.EMAILBCC
DOCATTR.SENDERADDRESS
DOCATTR.SENDERNAME
old text 3
DOCATTR.EXPIRATION
DOCATTR.PRIORITYNC
the secondary input is
1
2
That is too run from the command line, only not with @-it@ but @java -jar 'C:\Program Files\Saxonica\Saxon9.8HE\saxn9he.jar' -t -xsl:.\test201706270103.xsl -s:.\test2017062701.xml@ instead.
Problems are the same, 9.8 EE does not access it as streamable while 9.7 EE does, 9.8 EE when using @STREAMABLE=0@ runs the code fine with the wanted result, 9.8 HE does not build the map saying (as already shown above) "An empty sequence is not allowed as the value of variable $id-msg-map".
RE: Two problems with accumulators and a map trying to collect data - Added by Michael Kay over 7 years ago
The HE version of this is now running correctly after making the changes described under bug #3309.
Please register to reply