Pages

[DOM] Problème de transformation XML sujet

mercredi 29 janvier 2014




Bonjour
je suis entrain de concevoir une solution pour la transformation de fichiers xml, j'utilise comme plateforme de developpoement : weblogic 12, le projet est compilé avec jdk1.4, je retrouve toujours l'erreur suivante :

ERREUR : ''
ERREUR : 'java.lang.NullPointerException'
javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: java.lang.NullPointerException
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:719)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:313)

j'utilise le bout de code suivant pour la transformation :
public static byte[] transformerXml(Document document, String xsl) {
try{
ByteArrayOutputStream os = new ByteArrayOutputStream();
Result resultat = new StreamResult(os);

// Configuration du transformer
TransformerFactory fabrique = TransformerFactory.newInstance();
//StreamSource stylesource = new StreamSource(new File(xsl));
//InputStream stream = new ByteArrayInputStream(xmlPrint(document).getBytes("UTF-8"));
//StreamSource docSource = new StreamSource(f);
StreamSource stylesource = new StreamSource(Thread.currentThread().getContextClassLoader().getResourceAsStream(xsl));
Transformer transformer = fabrique.newTransformer(stylesource);

transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");

// Transformation
transformer.transform(new DOMSource(document), resultat);
} catch (Exception e) {
e.printStackTrace();
}
}

n.b : ce code marche bien sous weblogic 8.1

Merci




Aucun commentaire:

Enregistrer un commentaire