Mohana,
I would look in the "out" byte array and see what it looks
like. By doing xo.save(...) (by the way, who is "xo"?) you completely bypass
XmlBeans, so it's a matter of what document are you really
loading.
It would be more interesting, from an XmlBeans
perspective, to know what results you get from XmlObject.getDomNode() and
XmlObject.newDomNode()
Radu From: Mohana Ramaratnam [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 18, 2006 12:59 PM To: user@xmlbeans.apache.org Subject: XMLBeans DOM Document I am trying to get a DOM document to
be then used with Xalan’s XPathAPI. This is the code that I
have:
String xmlFile
= "dom.xml";
XmlObject xmlObject = new
XmlReader().read(xmlFile);
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
//
MUST be TRUE or can't get back to bean land
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
//
Switch to org.w3c.dom.Document - xmlbeans.getDomNode()
doesn't
//
really seem to give you this
ByteArrayOutputStream out = new
ByteArrayOutputStream();
xo.save(out,new
XmlOptions().setSavePrettyPrint());
Document doc = builder.parse(new
InputSource(new
ByteArrayInputStream(out.toByteArray()))); NodeList
nodes = XPathAPI.selectNodeList(doc,"/Pipeline");
System.out.println("Number
of nodes is "
+ nodes.getLength());
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = dbf.newDocumentBuilder();
Document doc1 = builder.parse( new
File(xmlFile));
NodeList nodes1 = XPathAPI.selectNodeList(doc1,"/Pipeline");
System.out.println("Number
of nodes is "
+ nodes1.getLength()); I get two
different answers in the system out. Any ideas as to what could be wrong in
creating a DOM document from a XMLBeans object? _______________________________________________________________________ Notice: This email message, together with any attachments, may contain information of BEA Systems, Inc., its subsidiaries and affiliated entities, that may be confidential, proprietary, copyrighted and/or legally privileged, and is intended solely for the use of the individual or entity named in this message. If you are not the intended recipient, and have received this message in error, please immediately return this by email and then delete it. |
- XMLBeans DOM Document Mohana Ramaratnam
- RE: XMLBeans DOM Document Radu Preotiuc-Pietro