M
Mathieu
Hello,
I 'd like to transform xml into another xml by using xslt.
My problem is that input xml and xslt are not in files but in strings.
Moreover output xml must be in string (because I use a database)
My code which doesn't work :
private String convertXML(String xml, String xslt) throws
TransformerException {
SAXResult xmlresult = new SAXResult();
Source xmlsource = new StreamSource(new
StringBufferInputStream(xml));
TransformerFactory xsltfactory = TransformerFactory.newInstance();
Transformer xsltengine = xsltfactory.newTransformer(new
StreamSource(new StringReader(xslt)));
xsltengine.transform(xmlsource,xmlresult);
return xmlresult.toString();
}
The result is bad
Have you got an idea ?
Thanks
I 'd like to transform xml into another xml by using xslt.
My problem is that input xml and xslt are not in files but in strings.
Moreover output xml must be in string (because I use a database)
My code which doesn't work :
private String convertXML(String xml, String xslt) throws
TransformerException {
SAXResult xmlresult = new SAXResult();
Source xmlsource = new StreamSource(new
StringBufferInputStream(xml));
TransformerFactory xsltfactory = TransformerFactory.newInstance();
Transformer xsltengine = xsltfactory.newTransformer(new
StreamSource(new StringReader(xslt)));
xsltengine.transform(xmlsource,xmlresult);
return xmlresult.toString();
}
The result is bad
Have you got an idea ?
Thanks