This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Transformer - omitting the xml header ( Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Transformer - omitting the xml header (" ?xml encoding=.. ?" )" Watch "Transformer - omitting the xml header (" ?xml encoding=.. ?" )" New topic
Author

Transformer - omitting the xml header (" ?xml encoding=.. ?" )

Sol Mayer-Orn
Ranch Hand

Joined: Nov 13, 2002
Posts: 311
Hi,

I'm trying to use Transformer in order to convert a DOM Node into a string.
This works, but unfortunately it sticks the xml header at the beginning of the string : < ?xml ... >
For my particular application, I don't need this xml header. So how do you tell the transformer to avoid printing it ?

That's my code so far:



Thanks
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18541
    
    8

If you were doing an XSLT transformation, then you would use <xslutput omit-xml-declaration="yes"/>. So in your code I would tryThat's my best guess.

Bear in mind that the transformer cannot omit the XML declaration unless the encoding of the document it is writing is UTF-8. Any other encoding has to be specified in an XML declaration.
[ February 05, 2006: Message edited by: Paul Clapham ]
 
Consider Paul's rocket mass heater.
 
subject: Transformer - omitting the xml header (" ?xml encoding=.. ?" )
 
Similar Threads
XML doument to a string
creating a DOM document from an XML file.
Reading child tags as separate xml blocks
What Replaced org.apache.xml.serialize.XMLSerializer and org.apache.xml.serialize.OutputFormat
Inserting node in XMl and retaining doc type information