Hi, If you want to serialize the original XML document, instead of getting the document element use the OMDocument.
So you can do the following, OMDocument doc = builder.getDocument(); doc.serialize(System.out); This works, I'll have to look into the formatting thing and will come up with a reply soon. Thanks, Saliya -- http://esaliya.blogspot.com On Wed, Jul 16, 2008 at 1:10 PM, William Boyd <[EMAIL PROTECTED]>wrote: > hello list, > > i'm trying to learn AXIOM using version 1.2.6. > > i've got some original xml coming into one end of my app that has an xml > declaration at the top. i'm trying to serialize it out at the other end of > my app with the xml declaration intact. so, along the way, i create an > OMOutputFormat (myOutputFormat), i call setIgnoreXmlDeclaration(false), i > slurp in the original file with an XMLStreamReader, build it with a > StAXOMBuilder, and to examine the progress, i serialize it to stdout: > > //create the parser > XMLStreamReader parser = > XMLInputFactory.newInstance().createXMLStreamReader(new > FileInputStream(file)); > > > //create the builder > StAXOMBuilder builder = new StAXOMBuilder(parser); > > //get the root element (in this case the envelope) > OMElement myOMElement = builder.getDocumentElement(); > > OMOutputFormat myOutputFormat = new OMOutputFormat(); > > myOutputFormat.setIgnoreXmlDeclaration(false) > > myOMElement.serialize(System.out, myOutputFormat); > > but the xml declaration - which exists in the original document - is not > present in the serialized output. am i missing any steps? i also tried > calling myOutputFormat.getContentType() AFTER calling > myOutputFormat.ignoreXmlDeclaration(false) because the javadoc for > OMOutputFormat says "Setting of all the properties in a OMOutputFormat > should be done before calling the getContentType() method.". i've also > tried > using an XMLStreamWriter instead of stdout. same result. what steps have i > missed? > > thanks in advance for your help. > > many thanks, > sun_certified > -- Saliya Ekanayake http://www.esaliya.blogspot.com http://www.esaliya.wordpress.com
