Hi to all of you,
I hava a simply problem that could not solve. I am using
javax.xml.Trans form. I am trying to transform Documtne to xml file. I
am setting transformer.set OutputProperty( OutputKeys.INDE NT,"no")
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(ou tputStream);
Transformer transformer = null;
try
{
transformer = transformerFact ory.newTransfor mer();
}
catch(Transform erConfiguration Exception tce)
{
throw new DOMTransformati onException(tce );
}
transformer.set OutputProperty( OutputKeys.METH OD,"xml");
String indent = (isIntended ? "yes" : "no");
System.out.prin tln(indent);
transformer.set OutputProperty( OutputKeys.INDE NT,indent);
transformer.set Parameter(Outpu tKeys.INDENT,in dent);
//transformer.set OutputProperty( OutputKeys.VERS ION,)
if(root instanceof Document)
{
transformer.set OutputProperty( OutputKeys.OMIT _XML_DECLARATIO N,"no");
}
else if(root instanceof Element)
{
transformer.set OutputProperty( OutputKeys.OMIT _XML_DECLARATIO N,"yes");
}
try
{
transformer.tra nsform(domSourc e,result);
}
catch(Transform erException te)
{
throw new DOMTransformati onException(te) ;
}
i expect: <root><somethin g/></root>
but it is:
<root>
<something/>
</root>
the (Node root) is coming from pretty formated xml.
I am waiting for your help.
jivko
I hava a simply problem that could not solve. I am using
javax.xml.Trans form. I am trying to transform Documtne to xml file. I
am setting transformer.set OutputProperty( OutputKeys.INDE NT,"no")
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(ou tputStream);
Transformer transformer = null;
try
{
transformer = transformerFact ory.newTransfor mer();
}
catch(Transform erConfiguration Exception tce)
{
throw new DOMTransformati onException(tce );
}
transformer.set OutputProperty( OutputKeys.METH OD,"xml");
String indent = (isIntended ? "yes" : "no");
System.out.prin tln(indent);
transformer.set OutputProperty( OutputKeys.INDE NT,indent);
transformer.set Parameter(Outpu tKeys.INDENT,in dent);
//transformer.set OutputProperty( OutputKeys.VERS ION,)
if(root instanceof Document)
{
transformer.set OutputProperty( OutputKeys.OMIT _XML_DECLARATIO N,"no");
}
else if(root instanceof Element)
{
transformer.set OutputProperty( OutputKeys.OMIT _XML_DECLARATIO N,"yes");
}
try
{
transformer.tra nsform(domSourc e,result);
}
catch(Transform erException te)
{
throw new DOMTransformati onException(te) ;
}
i expect: <root><somethin g/></root>
but it is:
<root>
<something/>
</root>
the (Node root) is coming from pretty formated xml.
I am waiting for your help.
jivko