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

Reply via email to