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
is.
Probably I am missing something and I'll be thankfull if someont could
help.
here is some code:
DOMSource domSource = new DOMSource(root);
StreamResult result = new StreamResult(outputStream);
Transformer transformer = null;
try
{
transformer = transformerFactory.newTransformer();
}
catch(TransformerConfigurationException tce)
{
throw new DOMTransformationException(tce);
}
transformer.setOutputProperty(OutputKeys.METHOD,"x ml");
String indent = (isIntended ? "yes" : "no");
System.out.println(indent);
transformer.setOutputProperty(OutputKeys.INDENT,in dent);
transformer.setParameter(OutputKeys.INDENT,indent) ;
//transformer.setOutputProperty(OutputKeys.VERSION,)
if(root instanceof Document)
{
transformer.setOutputProperty(OutputKeys.OMIT_XML_ DECLARATION,"no");
}
else if(root instanceof Element)
{
transformer.setOutputProperty(OutputKeys.OMIT_XML_ DECLARATION,"yes");
}
try
{
transformer.transform(domSource,result);
}
catch(TransformerException te)
{
throw new DOMTransformationException(te);
}
i expect: <root><something/></root>
but it is:
<root>
<something/>
</root>
the (Node root) is coming from pretty formated xml.
I am waiting for your help.
jivko