PLEASE DO NOT REPLY TO THIS MESSAGE. TO FURTHER COMMENT ON THE STATUS OF THIS BUG PLEASE FOLLOW THE LINK BELOW AND USE THE ON-LINE APPLICATION. REPLYING TO THIS MESSAGE DOES NOT UPDATE THE DATABASE, AND SO YOUR COMMENT WILL BE LOST SOMEWHERE. http://nagoya.apache.org/bugzilla/show_bug.cgi?id=3429 *** shadow/3429 Tue Sep 4 22:11:39 2001 --- shadow/3429.tmp.780 Tue Sep 4 22:11:39 2001 *************** *** 0 **** --- 1,78 ---- + +============================================================================+ + | 2.2.D10: a namespace node disappears | + +----------------------------------------------------------------------------+ + | Bug #: 3429 Product: XalanJ2 | + | Status: NEW Version: 2.2.x | + | Resolution: Platform: All | + | Severity: Major OS/Version: Windows NT/2K | + | Priority: Other Component: org.apache.xpath | + +----------------------------------------------------------------------------+ + | Assigned To: [EMAIL PROTECTED] | + | Reported By: [EMAIL PROTECTED] | + | CC list: Cc: | + +----------------------------------------------------------------------------+ + | URL: | + +============================================================================+ + | DESCRIPTION | + I expects the following code prints: + + xmlns 'urn:x-default1' + xmlns:a 'urn:x-unused' + xmlns 'urn:x-default2' + + or + + xmlns 'urn:x-default1' + xmlns 'urn:x-default2' + xmlns:a 'urn:x-unused' + + With Xalan-J 2.2.D10 it prints: + + xmlns 'urn:x-default1' + xmlns 'urn:x-default2' + + There is no xmlns:a node. + + + Note: In fact, it should prints five namespace nodes according to XPath 1.0 + standard. This bug would be solved if Bugzilla #2650 is fixed completely. + But I guess a cause of this bug is not the same as #2650. + + This and #2650 cause significant problems for XML-Signature. + + + import java.io.StringReader; + import org.apache.xpath.XPath; + import org.apache.xpath.XPathAPI; + import org.apache.xpath.objects.XObject; + import org.apache.xerces.parsers.DOMParser; + import org.w3c.dom.Document; + import org.w3c.dom.Node; + import org.w3c.dom.traversal.NodeIterator; + import org.xml.sax.InputSource; + + public class XPathBug { + public static void main(String[] argv) throws Exception { + final String docStr = + "<bookOrder xmlns='urn:x-default1'>\n"+ + " <item xmlns:a='urn:x-unused' xmlns='urn:x-default2'/>\n"+ + "</bookOrder>\n"; + DOMParser domp = new DOMParser(); + domp.parse(new InputSource(new StringReader(docStr))); + Document doc = domp.getDocument(); + + String xpathStr = "//namespace::*"; + + XObject xobj = XPathAPI.eval(doc, xpathStr); + if (xobj.getType() != XObject.CLASS_NODESET) { + System.err.println("Non-nodeset: Fail"); + } else { + NodeIterator iter = xobj.nodeset(); + Node n; + while ((n = iter.nextNode()) != null) { + System.out.println(n.getNodeName()+" '"+n.getNodeValue()+"'"); + } + iter.detach(); + } + } + }
