[ http://issues.apache.org/jira/browse/XALANJ-1363?page=all ]
Brian Minchau updated XALANJ-1363: ---------------------------------- Version: Latest Development Code (was: 2.4) > XNodeSet.getStringFromNode() gives NullPointerException > ------------------------------------------------------- > > Key: XALANJ-1363 > URL: http://issues.apache.org/jira/browse/XALANJ-1363 > Project: XalanJ2 > Type: Bug > Components: XPath > Versions: Latest Development Code > Environment: Operating System: All > Platform: All > Reporter: art_w > Assignee: Xalan Developers Mailing List > > 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. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]