You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Gary L Peskin <ga...@firstech.com> on 2000/07/14 23:29:57 UTC

[Xalan-J] Misleading error message and fix

The following XML document:

<?xml version="1.0"?>
<root/>

And stylesheet:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:variable name="foo">Test RTF</xsl:variable>
<xsl:template match="root">
  <xsl:for-each select="$foo">
    <xsl:value-of select="." />
  </xsl:for-each>
</xsl:template>
</xsl:stylesheet>

Yields the error message:  Can not convert #UNKNOWN to a NodeList!

This is misleading.  It is due to the fact that
org.apache.xalan.xpath.XObject.getTypeString() is declared private so
the actual type string will always be "#UNKNOWN" rather than the
specific type.

To correct this, the getTypeString() method should be changed from
private to protected in each of the following classes in package
org.apache.xalan.xpath:

XObject and its descendants:
  XBoolean
  XNodeSet
  XNull
  XNumber
  XRTreeFrag
  XString

This change yields the more sensible error message:

Can not convert #RTREEFRAG to a NodeList!

Gary