File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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

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

Sol Mayer-Orn
Ranch Hand

Joined: Nov 13, 2002
Posts: 311

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:

Paul Clapham

Joined: Oct 14, 2005
Posts: 19875

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 ]
I agree. Here's the link:
subject: Transformer - omitting the xml header (" ?xml encoding=.. ?" )
It's not a secret anymore!