Project

Profile

Help

Bug #2011

closed

xsl:number/@count pattern with predicates: failure to allocate stack frame slot

Added by Michael Kay about 10 years ago. Updated about 10 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Internals
Sprint/Milestone:
-
Start date:
2014-02-24
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:

Description

The attached code fails in 9.5.1.4, failed to allocate a stack frame slot for $id:

<xsl:stylesheet version="3.0"   
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
  xmlns:xs="http://www.w3.org/2001/XMLSchema" 
  xmlns:fn="http://www.w3.org/2005/xpath-functions" 
  xmlns:ecf2ncx="http://www.w3.org/2005/xpath-datatypes" 
  xmlns:saxon="http://saxon.sf.net/" 
  exclude-result-prefixes="xs ecf2ncx saxon fn">
  <xsl:mode name="s" streamable="yes"/>
  
<xsl:function name="ecf2ncx:get-num-toc" as="xs:string?">
		<xsl:param name="e" as="element()"/>
		<xsl:variable name="name" select="local-name($e)"/>
		<!-- Renumérotation à partir d'une entrée hiérarchiquement plus importante -->
		<xsl:variable name="id" select="generate-id($e/parent::*)"/>
		<xsl:choose>
			<xsl:when test="$e/@toc-addnum='true' or $e/@toc-addnum='single'">
				<xsl:number level="single" select="$e"	count="*[generate-id(parent::*)=$id][local-name(.)=$name and @toc-addnum=$e/@toc-addnum]"
														format="{$e/@toc-addnum-format}"/>
				<!--BUG SAXON ? : on aurait pu écrire count="*[generate-id(parent::*)=$id][local-name(.)=$name][@toc-addnum=$e/@toc-addnum]" mais cela génère un bogue saxon-->
			</xsl:when>
			<xsl:when test="$e/@toc-addnum='any'">
				<!--@toc-addnum-format possibles sont "1", "01", "a", "A", "i", "I" (idem xsl:number/@format).-->
				<xsl:number level="any" select="$e"	count="*[ local-name() = $name and @toc-addnum = $e/@toc-addnum ]"
													format="{$e/@toc-addnum-format}"/>
			</xsl:when>
		</xsl:choose>
</xsl:function>

<xsl:template name="main">
  <xsl:variable name="data">
    <e toc-addnum="single"/>
  </xsl:variable>
  <xsl:sequence select="ecf2ncx:get-num-toc($data/*)"/>
</xsl:template>
  
</xsl:stylesheet>

Reported on saxon-help SourceForge list by RICAUD-DUSSARGET Matthieu

Actions #1

Updated by Michael Kay about 10 years ago

First, there is a bug in PatternWithPredicate.analyze() - it calls typeCheck on the predicate, but fails to call analyze() on the basePattern, which means that only the last predicate gets type-checked. Since type checking causes the reference count of variables to be incremented, this means that the reference count of @id ends up as zero, causing the variable declaration to be optimized out.

Fixing this leaves another problem, however, related to the inlining of the variable id when the only reference to the variable is within a pattern. It seems that when the variable reference $id is replaced with the initializer local-name($e), the binding to $e is carried across correctly, but the slot number is not.

Actions #2

Updated by Michael Kay about 10 years ago

  • Status changed from New to Resolved

I fixed a couple more places where the class PatternWithPredicate fails to handle the case where there is more than one predicate. The test case now runs successfully.

Test case added to w3c test suite as number-0202.

Actions #3

Updated by O'Neil Delpratt about 10 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in version set to 9.5.1.5

Bug fix applied in Saxon maintenance release 9.5.1.5

Please register to edit this issue

Also available in: Atom PDF