You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Nathan Coast <na...@cableinet.co.uk> on 2001/05/09 00:45:26 UTC

newbie transform question

Hi,

I'm trying to do some basic transforms using xerces / xalan using code like 
below.  The problem is that whatever transform I do, I always get:

<?xml version="1.0" encoding="UTF-8"?>

at the start of the output.  The output isn't xml so I don't want this produced. 
Any ideas how to prevent the <?xml.... from being generated?

Thanks
Nathan


code:

Document doc= new DocumentImpl();
Element root = doc.createElement("myDocument");     // Create Root Element
root.setAttribute(.....
root.setAttribute(.....

TransformerFactory tFactory = TransformerFactory.newInstance();
Transformer transformer = tFactory.newTransformer(new StreamSource(myXSLFile));
transformer.transform(new DOMSource(root), StreamResult(System.out));


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: newbie transform question

Posted by Zhaohua Meng <me...@hotlens.com>.
When you construct an XMLSerializer, pass in 
an "org.apache.xml.serialize.OutputFormat" object, then call 
setOmitXMLDeclaration(true) on it.

Zhaohua Meng

Hotlens.com Inc.
http://www.hotlens.com

350 Fifth AVE
Suite 3113
New York, NY 10118
Phone: 212-465-1700
Fax:   212-465-1710
email: mengzh@hotlens.com


-----Original Message-----
From: Nathan Coast <na...@cableinet.co.uk>
To: xerces-j-user@xml.apache.org
Date: Thu, 10 May 2001 09:17:17 +0100
Subject: Re: newbie transform question

> resolution:
> 
> transformer.setOutputProperty(OutputKeys.METHOD,"text");
> 
> 
> Nathan Coast wrote:
> 
> > Hi,
> > 
> > I'm trying to do some basic transforms using xerces / xalan using
> code 
> > like below.  The problem is that whatever transform I do, I always
> get:
> > 
> > <?xml version="1.0" encoding="UTF-8"?>
> > 
> > at the start of the output.  The output isn't xml so I don't want
> this 
> > produced. Any ideas how to prevent the <?xml.... from being
> generated?
> > 
> > Thanks
> > Nathan
> > 
> > 
> > code:
> > 
> > Document doc= new DocumentImpl();
> > Element root = doc.createElement("myDocument");     // Create Root
> Element
> > root.setAttribute(.....
> > root.setAttribute(.....
> > 
> > TransformerFactory tFactory = TransformerFactory.newInstance();
> > Transformer transformer = tFactory.newTransformer(new 
> > StreamSource(myXSLFile));
> > transformer.transform(new DOMSource(root),
> StreamResult(System.out));
> > 
> > 
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> > For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: newbie transform question

Posted by Nathan Coast <na...@cableinet.co.uk>.
resolution:

transformer.setOutputProperty(OutputKeys.METHOD,"text");


Nathan Coast wrote:

> Hi,
> 
> I'm trying to do some basic transforms using xerces / xalan using code 
> like below.  The problem is that whatever transform I do, I always get:
> 
> <?xml version="1.0" encoding="UTF-8"?>
> 
> at the start of the output.  The output isn't xml so I don't want this 
> produced. Any ideas how to prevent the <?xml.... from being generated?
> 
> Thanks
> Nathan
> 
> 
> code:
> 
> Document doc= new DocumentImpl();
> Element root = doc.createElement("myDocument");     // Create Root Element
> root.setAttribute(.....
> root.setAttribute(.....
> 
> TransformerFactory tFactory = TransformerFactory.newInstance();
> Transformer transformer = tFactory.newTransformer(new 
> StreamSource(myXSLFile));
> transformer.transform(new DOMSource(root), StreamResult(System.out));
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-user-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org