[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Why is pattern item/bar/text()[accumulator-before('co

Subject: Why is pattern item/bar/text()[accumulator-before('collect-foo') eq $search] not motionless?
From: "Martin Honnen martin.honnen@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 3 Jan 2016 12:16:07 -0000
 Why is pattern  item/bar/text()[accumulator-before('co
I am using streaming with an accumulator with Saxon 9.7 EE, I have a global variable

<xsl:param name="search" as="xs:string" select="'searched foo'"/>

and an accumulator

<xsl:accumulator name="collect-foo" as="xs:string?" initial-value="()" streamable="yes">
<xsl:accumulator-rule match="item/foo/text()">
<xsl:sequence select="string()"/>
</xsl:accumulator-rule>
</xsl:accumulator>


and I would like to write a pattern using that accumulator value and compare it to the global variable, as in

<xsl:template match="item/bar/text()[accumulator-before('collect-foo') eq $search]">
<xsl:value-of select="$replace"/>
</xsl:template>


but Saxon complains

XTSE3430: Template rule is declared streamable but it does not satisfy the streamability rules.
* The match pattern is not motionless


When I rewrite the template to have the check inside, as in

<xsl:template match="item/bar/text()">
<xsl:value-of select="if (accumulator-before('collect-foo') eq $search) then $replace else ."/>
</xsl:template>


all works fine.

http://www.w3.org/TR/xslt-30/#streamability-fn-accumulator-before with "If the argument to accumulator-before is motionless, the function call is grounded and motionless." sounds as if the call to `accumulator-before` with a string literal as the argument should be fine.

For completeness, the full stylesheet 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:map="http://www.w3.org/2005/xpath-functions/map" exclude-result-prefixes="xs map" version="3.0">

<xsl:param name="search" as="xs:string" select="'searched foo'"/>
<xsl:param name="replace" as="xs:string" select="'new bar value'"/>

<xsl:mode streamable="yes" on-no-match="shallow-copy"/>
<xsl:global-context-item use-accumulators="collect-foo"/>

<xsl:accumulator name="collect-foo" as="xs:string?" initial-value="()" streamable="yes">
<xsl:accumulator-rule match="item/foo/text()">
<xsl:sequence select="string()"/>
</xsl:accumulator-rule>
</xsl:accumulator>


<xsl:template match="item/bar/text()[accumulator-before('collect-foo') eq $search]">
<xsl:value-of select="$replace"/>
</xsl:template>


</xsl:stylesheet>

a sample input document is

<root>
  <item-list>
    <item>
      <foo>foo 1</foo>
      <bar>bar 1</bar>
    </item>
    <item>
      <foo>searched foo</foo>
      <bar>bar 2</bar>
    </item>
    <item>
      <foo>foo 3</foo>
      <bar>bar 3</bar>
    </item>
    <item>
      <foo>searched foo</foo>
      <bar>bar 4</bar>
    </item>
  </item-list>
</root>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.