|
[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
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
<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>
|
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
|

Cart








