Quantcast

Streamed xsl:accumulator in Saxon 9.7.0.1

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Streamed xsl:accumulator in Saxon 9.7.0.1

Julian Richter
Hi there

As I tried something using Streaming in Saxon 9.7.0.1 EE I ran into an error that could not be reproduced using Saxon 9.6.0.8 (i.e. it perfectly worked in the old version but not in the new one).

My setup:
OS X 10.11.2
Stylesheet written in Oxygen 17.1
Stylesheet processed in Terminal.app with both mentioned versions of Saxon (Java)

The error in the Terminal states the following:
Error at char 19 in xsl:value-of/@select on line 31 column 68 of accumulators.xsl:
  XTDE3362: The accumulator lfNr is not in use for the current streamed document (check
  @use-accumulators)
The accumulator lfNr is not in use for the current streamed document (check @use-accumulators)

With the following stylesheet:
<?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:output indent="yes"/>

   
<xsl:accumulator name="lfNr" initial-value="0" as="xs:integer" streamable="yes">
       
<xsl:accumulator-rule match="/Books" select="0"/>
       
<xsl:accumulator-rule match="/Books/Book" select="$value + 1"/>
   
</xsl:accumulator>
   
   
<xsl:mode streamable="yes" on-no-match="deep-copy"/>

   
<xsl:template match="/">
       
<xsl:apply-templates/>
   
</xsl:template>

   
<xsl:template match="Books">
       
<Books>
           
<xsl:apply-templates/>
       
</Books>
   
</xsl:template>

   
<xsl:template match="Book">
       
<Book>
           
<xsl:copy-of select="@*"/>
           
<xsl:apply-templates/>
           
<lfNr>
               
<xsl:value-of select="accumulator-before('lfNr')"/>
           
</lfNr>
       
</Book>
   
</xsl:template>

</xsl:stylesheet>

My XML file looks like this (of course with more <Book/> elements):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Books>
<Book authors="Ken Follett" isbn13="9780061364723">
<first_name>Ken</first_name>
<last_name>Follett</last_name>
<title>Triple</title>
<status>Completed</status>
<publisher>Harper</publisher>
<pages>416</pages>
<asin>006136472X</asin>
<isbn10>006136472X</isbn10>
</Book>
<Book authors="Thomas Pynchon" isbn13="9780061849923">
<first_name>Thomas</first_name>
<last_name>Pynchon</last_name>
<title>Crying of Lot 49, The</title>
<status>Completed</status>
<publisher>Harper Perennial</publisher>
<pages>192</pages>
<asin>61849928</asin>
<isbn10>61849928</isbn10>
</Book>
</Books>

Do I miss something obvious here?


Kind regards and thanks for the help in advance,
Julian

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 

signature.asc (859 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Streamed xsl:accumulator in Saxon 9.7.0.1

Michael Kay
This reflects a change in the XSLT 3.0 spec.

Accumulators are now maintained for a streamed document only if explicitly requested (this allows different accumulators to be maintained for different streamed inputs, e.q.g when merging documents).

In your case, where the streamed document is supplied as the initial source document, this should be specified as

<xsl:global-context-item streamable="true" use-accumulators="IfNr"/>

Please also note an open bug on 9.7


Michael Kay
Saxonica

On 13 Jan 2016, at 19:52, Julian Richter <[hidden email]> wrote:

Hi there

As I tried something using Streaming in Saxon 9.7.0.1 EE I ran into an error that could not be reproduced using Saxon 9.6.0.8 (i.e. it perfectly worked in the old version but not in the new one).

My setup:
OS X 10.11.2
Stylesheet written in Oxygen 17.1
Stylesheet processed in Terminal.app with both mentioned versions of Saxon (Java)

The error in the Terminal states the following:
Error at char 19 in xsl:value-of/@select on line 31 column 68 of accumulators.xsl:
  XTDE3362: The accumulator lfNr is not in use for the current streamed document (check
  @use-accumulators)
The accumulator lfNr is not in use for the current streamed document (check @use-accumulators)

With the following stylesheet:
<?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:output indent="yes"/>

   
<xsl:accumulator name="lfNr" initial-value="0" as="xs:integer" streamable="yes">
       
<xsl:accumulator-rule match="/Books" select="0"/>
       
<xsl:accumulator-rule match="/Books/Book" select="$value + 1"/>
   
</xsl:accumulator>
   
   
<xsl:mode streamable="yes" on-no-match="deep-copy"/>

   
<xsl:template match="/">
       
<xsl:apply-templates/>
   
</xsl:template>

   
<xsl:template match="Books">
       
<Books>
           
<xsl:apply-templates/>
       
</Books>
   
</xsl:template>

   
<xsl:template match="Book">
       
<Book>
           
<xsl:copy-of select="@*"/>
           
<xsl:apply-templates/>
           
<lfNr>
               
<xsl:value-of select="accumulator-before('lfNr')"/>
           
</lfNr>
       
</Book>
   
</xsl:template>

</xsl:stylesheet>

My XML file looks like this (of course with more <Book/> elements):
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Books>
<Book authors="Ken Follett" isbn13="9780061364723">
<first_name>Ken</first_name>
<last_name>Follett</last_name>
<title>Triple</title>
<status>Completed</status>
<publisher>Harper</publisher>
<pages>416</pages>
<asin>006136472X</asin>
<isbn10>006136472X</isbn10>
</Book>
<Book authors="Thomas Pynchon" isbn13="9780061849923">
<first_name>Thomas</first_name>
<last_name>Pynchon</last_name>
<title>Crying of Lot 49, The</title>
<status>Completed</status>
<publisher>Harper Perennial</publisher>
<pages>192</pages>
<asin>61849928</asin>
<isbn10>61849928</isbn10>
</Book>
</Books>

Do I miss something obvious here?


Kind regards and thanks for the help in advance,
Julian
------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help


------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[hidden email]
https://lists.sourceforge.net/lists/listinfo/saxon-help 
Loading...