Bad parent pointer found in expression xsl:break
Added by Martin Honnen about 6 years ago
I have been using xsl:iterate
with xsl:break
to achieve an early exit on streamed processing as I only needed to count some elements of the first child of the root element, the code works fine but Saxon-EE 9.8.0.12J
emits an odd warning
*** Bad parent pointer found in expression xsl:break at file:/C:/SomePath/wrap-with-generated-xslt-with-fork4.xsl#21 ***
during stylesheet compilation (at least it emits the warning with option -t
before emitting "Stylesheet compilation time...") so I guess something is wrong.
The stylesheet is trying to generate a stylesheet, the code 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:axsl="http://www.w3.org/1999/XSL/Transform-alias" exclude-result-prefixes="#all"
version="3.0">
<xsl:param name="input-uri" as="xs:string" select="'input2.xml'"/>
<xsl:output indent="yes"/>
<xsl:namespace-alias stylesheet-prefix="axsl" result-prefix="xsl"/>
<xsl:mode on-no-match="shallow-skip" streamable="yes"/>
<xsl:template match="/" name="xsl:initial-template">
<xsl:variable name="stylesheet">
<xsl:variable name="number-of-groups" as="xs:integer">
<xsl:source-document href="{$input-uri}" streamable="yes">
<xsl:iterate select="file/line">
<xsl:if test="position() = 1">
<xsl:sequence select="count(copy-of()/entry)"/>
<xsl:break/>
</xsl:if>
</xsl:iterate>
</xsl:source-document>
</xsl:variable>
<axsl:stylesheet version="3.0">
<axsl:mode streamable="yes"/>
<axsl:template match="file">
<axsl:fork>
<xsl:for-each select="1 to $number-of-groups">
<axsl:sequence>
<axsl:element name="group{format-integer(., 'A')}">
<axsl:apply-templates select="line/entry[{.}]"/>
</axsl:element>
</axsl:sequence>
</xsl:for-each>
</axsl:fork>
</axsl:template>
<axsl:template match="entry/text()">
<observation value="{{.}}"/>
</axsl:template>
</axsl:stylesheet>
</xsl:variable>
<xsl:sequence select="$stylesheet"/>
<!--<xsl:sequence select="transform(map { 'source-location' : $input-uri, 'stylesheet-node' : $stylesheet })?output"/>-->
</xsl:template>
</xsl:stylesheet>
a sample input is (e.g. passed for the input-uri
parameter
<?xml version="1.0" encoding="UTF-8"?>
<file>
<line>
<entry>A1</entry>
<entry>B1</entry>
<entry>C1</entry>
<entry>D1</entry>
</line>
<line>
<entry>A2</entry>
<entry>B2</entry>
<entry>C2</entry>
<entry>D2</entry>
</line>
<line>
<entry>A3</entry>
<entry>B3</entry>
<entry>C3</entry>
<entry>D3</entry>
</line>
</file>
As | said, code runs fine, only the warning looks odd.
Replies (3)
Please register to reply
RE: Bad parent pointer found in expression xsl:break - Added by Michael Kay about 6 years ago
Thanks for reporting it. Saxon does internal integrity checks on the expression tree and this means that such a check has failed. The tree is repaired and execution continues, but we like to know about it.
RE: Bad parent pointer found in expression xsl:break - Added by Michael Kay about 6 years ago
Reproduced with 9.8.0.12 but not with 9.8.0.14 so I'm assuming it's been cleared, though I can't find a matching bug entry.
RE: Bad parent pointer found in expression xsl:break - Added by Michael Kay about 6 years ago
Looking more carefully, the integrity checks have all been removed in the current source code revision. If I put some checks back in then I get the error reported on entry to IterateInstr.typeCheck().
There's Block(count(copy-of)/entry, Break) that has the xsl:break instruction as a child; the child's parent pointer points to a different Block object with identical content. One of them was presumably created by copying the other.
Sure enough, BreakInstr.copy() returns the instruction unchanged rather than making a copy. That's incorrect.
Please register to reply