File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Spring in Action this week in the Spring 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: 18656
    
    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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Transformer - omitting the xml header (" ?xml encoding=.. ?" )