1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
| public XmlNode getCreateXml() throws DfException, SAXException, IOException, TransformerException
{
String result = null;
XMLReader analyseurSax = XMLReaderFactory.createXMLReader();
InputStream fis = new FileInputStream(xsl.getFile(null));
InputSource sourceEntreeXSL = new InputSource(fis);
SAXSource sourceXSL = new SAXSource(analyseurSax, sourceEntreeXSL);
XmlDocument xmlDoc = new XmlDocument();
InputSource sourceEntreeXML = new InputSource(xmlDoc.getInputStream());
SAXSource sourceXML = new SAXSource(analyseurSax, sourceEntreeXML);
TransformerFactory fabrique = TransformerFactory.newInstance();
Transformer transformateur = fabrique.newTransformer(sourceXSL);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Result sortie = new StreamResult(baos);
transformateur.transform(sourceXML, sortie);
result = new String(baos.toByteArray());
//analyseurSax.
fis.close();
baos.flush();
baos.close(); |
Partager