Value of variable is undefined
Added by Anonymous over 19 years ago
Legacy ID: #3302322 Legacy Poster: Dominique Hazaël-Massieux (nimbustier)
When applying the style sheet below on itself with saxon 8.5, saxon exists with the following Java exception: Exception in thread "main" java.lang.AssertionError: Value of variable is undefined (null) at net.sf.saxon.value.Value.getIterator(Value.java:227) at net.sf.saxon.value.Value.asItem(Value.java:78) at net.sf.saxon.expr.VariableReference.evaluateItem(VariableReference.java:224) [....] This error disappears: * when commenting out both call-template calls inside compare-child * and even more oddly when using the -T option in the command line I have tried with several versions of java, so I'm fairly convinced it's indeed a bug in saxon. Thanks! Dom <?xml-stylesheet href="http://www.w3.org/StyleSheets/base.css" type="text/css"?><?xml-stylesheet href="http://www.w3.org/2002/02/style-xsl.css" type="text/css"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" xmlns:html="http://www.w3.org/1999/xhtml" exclude-result-prefixes="html"> <!-- Output method XML --> <xsl:output method="xml" indent="yes" omit-xml-declaration="no" encoding="utf-8" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" /> <p class="copyright"><a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> ©2002-2005 <a href="http://www.w3.org/"><acronym title="World Wide Web Consortium">W3C</acronym></a><sup>®</sup> (<a href="http://www.csail.mit.edu/"><acronym title="Massachusetts Institute of Technology">MIT</acronym></a>, <a href="http://www.ercim.org/"><acronym title="European Research Consortium for Informatics and Mathematics">ERCIM</acronym></a>, <a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved. W3C <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>, <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and <a href="http://www.w3.org/Consortium/Legal/copyright-documents">document use</a> rules apply.</p> <xsl:template match="/"> <xsl:apply-templates select="/xsl:stylesheet/html:p"/> </xsl:template> <xsl:template match="/xsl:stylesheet/html:p"> <html> <xsl:call-template name="compare-childs"> <xsl:with-param name="element" select="document('/home/dom/WWW/2001/07/pubrules-copyright.xml')/html:html/html:body/html:p[@class='copyright']" /> </xsl:call-template> </html> </xsl:template> <xsl:template name="compare-childs"> <xsl:param name="element" /> <xsl:for-each select=""> <xsl:variable name="pos" select="position()" /> <xsl:message><xsl:copy-of select="$element/[position()=$pos]"/></xsl:message> <xsl:call-template name="compare-attributes"> <xsl:with-param name="node" select="$element/[position()=$pos]" /> </xsl:call-template> <xsl:if test="not(normalize-space(.)=normalize-space($element/[position()=$pos])) or not($element/[position()=$pos])"> <li> <span class="no">Incorrect text</span>: "<xsl:value-of select="normalize-space()" />" should be "<xsl:value-of select="$element/[position()=$pos]" />" .</li> </xsl:if> <xsl:call-template name="compare-childs"> <xsl:with-param name="element" select="$element/[position()=$pos]" /> </xsl:call-template> </xsl:for-each> </xsl:template> <xsl:template name="compare-attributes"> <xsl:param name="node" /> <xsl:variable name="node2" select="." /> <xsl:for-each select="$node/@"> <xsl:variable name="attribute-name" select="local-name()" /> <xsl:choose> <xsl:when test="not($node2/@[local-name()=$attribute-name])"> <li> <span class="no">Could not find attribute <xsl:value-of select="$attribute-name" /> in <xsl:copy-of select="$node2" /> </span> </li> </xsl:when> <xsl:otherwise> <xsl:if test="not(normalize-space($node2/@[local-name()=$attribute-name])=normalize-space(.))"> <li>Attribute <xsl:value-of select="$attribute-name" /> in <xsl:copy-of select="$node2" /> has the <span class="no">incorrect value</span> <xsl:value-of select="$node2/@*[local-name()=$attribute-name]" /> (should be <xsl:value-of select="." /> </li> </xsl:if> </xsl:otherwise> </xsl:choose> </xsl:for-each> </xsl:template> </xsl:stylesheet>
Replies (7)
Please register to reply
RE: Value of variable is undefined - Added by Anonymous over 19 years ago
Legacy ID: #3302328 Legacy Poster: Dominique Hazaël-Massieux (nimbustier)
Sorry, to be able to run it anywhere, replace the document('/home/dom/WWW/2001/07/pubrules-copyright.xml') with document('http://www.w3.org/2001/07/pubrules-copyright.xml')
RE: Value of variable is undefined - Added by Anonymous over 19 years ago
Legacy ID: #3302352 Legacy Poster: Michael Kay (mhkay)
Thanks, Dominique - this is definitely a bug. I'll look into it - probably after the weekend. It's not odd that such bugs go away when using -T, because compiling trace code into the expression tree has the side effect of suppressing many tree-rewriting optimizations. Michael Kay
RE: Value of variable is undefined - Added by Anonymous over 19 years ago
Legacy ID: #3302396 Legacy Poster: Michael Kay (mhkay)
Sorry, but the stylesheet has been corrupted by the copy/paste operation. Could you possibly put it as an attachment in hte "support requests" section of the site, or just email it to me direct? Michael Kay
RE: Value of variable is undefined - Added by Anonymous over 19 years ago
Legacy ID: #3304977 Legacy Poster: Dominique Hazaël-Massieux (nimbustier)
RE: Value of variable is undefined - Added by Anonymous over 19 years ago
Legacy ID: #3305084 Legacy Poster: Michael Kay (mhkay)
Sorry, but there's no attachment. (This happens sometimes. You have to enter the filename, tick the checkbox, and click "Submit changes".)
RE: Value of variable is undefined - Added by Anonymous over 19 years ago
Legacy ID: #3305257 Legacy Poster: Dominique Hazaël-Massieux (nimbustier)
Oops! Should be there now... Sorry I'm making this so hard :)
RE: Value of variable is undefined - Added by Anonymous over 19 years ago
Legacy ID: #3306343 Legacy Poster: Michael Kay (mhkay)
I've registered this bug and published a source fix at https://sourceforge.net/tracker/index.php?func=detail&aid=1266525&group_id=29872&atid=397617 The construct that is causing the problem is the with-param select expression in <xsl:call-template name="compare-childs"> <xsl:with-param name="element" select="$element/*[position()=$pos]" /> </xsl:call-template> If you don't want to rebuild the Saxon code, you could circumvent the problem by changing the predicate to [position() - $pos = 0] which the optimizer isn't clever enough to meddle with. I'm hoping to get an 8.5.1 release out in the next couple of weeks that will have this fixed. Michael Kay
Please register to reply