You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by bu...@apache.org on 2002/12/18 00:39:55 UTC
DO NOT REPLY [Bug 15466] New: -
XNodeSet.getStringFromNode() gives NullPointerException
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15466>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=15466
XNodeSet.getStringFromNode() gives NullPointerException
Summary: XNodeSet.getStringFromNode() gives NullPointerException
Product: XalanJ2
Version: 2.4
Platform: All
OS/Version: All
Status: NEW
Severity: Normal
Priority: Other
Component: org.apache.xpath
AssignedTo: xalan-dev@xml.apache.org
ReportedBy: art_w@eastpoint.com
In XNodeSet.getStringFromNode() there is the following code:
public XMLString getStringFromNode(int n)
{
// %OPT%
// I guess we'll have to get a static instance of the DTM manager...
if(DTM.NULL != n)
{
return m_dtmMgr.getDTM(n).getStringValue(n);
}
else
{
return org.apache.xpath.objects.XString.EMPTYSTRING;
}
}
The comment indicates awareness that if m_dtmMgr is null there will be a
problem. Some other methods also contain similar code. Some XNodeSet
instantiations will result in the m_dtmMgr not being set. My initial thought
was to use getDTMManager() on the iterator in the constructor to set the
m_dtmMgr, this fixed some cases, but broke others (I was not able to figure out
why). I then implemented a change in getStringFromNode(), getNumberFromNode(),
and dispatchCharactersEvents() that seems to work in all cases that I tested.
This change is similar to the following example with getStringFromNode():
public XMLString getStringFromNode(int n)
{
// %OPT%
// I guess we'll have to get a static instance of the DTM manager...
if(DTM.NULL != n)
{
if ( m_dtmMgr != null )
return m_dtmMgr.getDTM(n).getStringValue(n);
else
return m_iter.getDTMManager().getDTM(n).getStringValue(n);
}
else
{
return org.apache.xpath.objects.XString.EMPTYSTRING;
}
}
Basically if m_dtmMgr is not set then use m_iter.getDTMManager() to get the DTM
manager. As I said, in my testing this works. My only concerns are that the
comment indicates an awareness of the issue - but this simple change had not
been made, and that perhaps a better solution is/was in the works.