By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,955 Members | 1,768 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,955 IT Pros & Developers. It's quick & easy.

Transform problem

P: n/a
Hi to all of you,
I hava a simply problem that could not solve. I am using
javax.xml.Transform. I am trying to transform Documtne to xml file. I
am setting transformer.setOutputProperty(OutputKeys.INDENT,"n o")
because i do not want the xml to be formated ... but in the output it
Probably I am missing something and I'll be thankfull if someont could

here is some code:

DOMSource domSource = new DOMSource(root);
StreamResult result = new StreamResult(outputStream);

Transformer transformer = null;
transformer = transformerFactory.newTransformer();
catch(TransformerConfigurationException tce)
throw new DOMTransformationException(tce);

transformer.setOutputProperty(OutputKeys.METHOD,"x ml");
String indent = (isIntended ? "yes" : "no");
transformer.setOutputProperty(OutputKeys.INDENT,in dent);
transformer.setParameter(OutputKeys.INDENT,indent) ;

if(root instanceof Document)
transformer.setOutputProperty(OutputKeys.OMIT_XML_ DECLARATION,"no");
else if(root instanceof Element)
transformer.setOutputProperty(OutputKeys.OMIT_XML_ DECLARATION,"yes");
catch(TransformerException te)
throw new DOMTransformationException(te);

i expect: <root><something/></root>

but it is:

the (Node root) is coming from pretty formated xml.

I am waiting for your help.
Jul 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.