http://nagoya.apache.org/bugzilla/show_bug.cgi?id=2322 *** shadow/2322 Tue Jun 26 01:01:23 2001 --- shadow/2322.tmp.17538 Tue Jun 26 01:01:23 2001 *************** *** 0 **** --- 1,89 ---- + +============================================================================+ + | Infinite loop in TreeWalkerImpl | + +----------------------------------------------------------------------------+ + | Bug #: 2322 Product: Xerces-J | + | Status: NEW Version: 1.4 | + | Resolution: Platform: Other | + | Severity: Normal OS/Version: Other | + | Priority: Other Component: DOM | + +----------------------------------------------------------------------------+ + | Assigned To: [EMAIL PROTECTED] | + | Reported By: [EMAIL PROTECTED] | + | CC list: Cc: | + +----------------------------------------------------------------------------+ + | URL: | + +============================================================================+ + | DESCRIPTION | + I ran into a infinite loop when acceptNode() returns FILTEP_SKIP in + TreeWalkerImpl class. Here are changes I made to fix the problem. + + Node getNextSibling(Node node) { + + if (node == null || node == fRoot) return null; + + Node newNode = node.getNextSibling(); + if (newNode == null) { + return null; + } + + int accept = acceptNode(newNode); + + if (accept == NodeFilter.FILTER_ACCEPT) { + return newNode; + } + else if (accept == NodeFilter.FILTER_SKIP) { + Node fChild = getFirstChild(newNode); + if (fChild == null) { + return getNextSibling(newNode); + } + return fChild; + } + else { //if (accept == NodeFilter.REJECT_NODE) + return getNextSibling(newNode); + } + + } + + + /** Internal function. + * Return the first child Node, from the input node + * after applying filter, whatToshow. + * The current node is not consulted or set. + */ + Node getFirstChild(Node node) { + Node childNode= null; + + if (node == null) { + return null; + } + + if ( !fEntityReferenceExpansion + && node.getNodeType() == Node.ENTITY_REFERENCE_NODE) { + return null; + } + + childNode = node.getFirstChild(); + if (childNode == null) { + return null; + } + + int accept = acceptNode(childNode); + + if (accept == NodeFilter.FILTER_ACCEPT) { + return childNode; + } + else if (accept == NodeFilter.FILTER_SKIP + && childNode.hasChildNodes()) { + Node descendentNode= getFirstChild(childNode); + if (null == descendentNode) { + return getNextSibling(childNode);; + } + else { + return descendentNode; + } + } + else { //if (accept == NodeFilter.REJECT_NODE) + Node siblingNode= getNextSibling(childNode); + return siblingNode; + } + } \ No newline at end of file --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
