Quels classes utiliser pour remplacer des classes qui sont propriété de Sun
Bonjour,
je souhaite récupérer sous forme de chaine de caractères indentée un objet de type org.w3c.dom.Document.
En cherchant sur le net, j'ai trouvé ce code là :
Code:
1 2 3 4 5 6 7 8 9 10 11
|
ByteArrayOutputStream bos = new ByteArrayOutputStream();
Properties OP = OutputPropertiesFactory.getDefaultMethodProperties("xml");
OP.setProperty(OutputKeys.METHOD,"xml");
OP.setProperty(OutputKeys.INDENT,"yes");
OP.setProperty(OutputKeys.ENCODING,"UTF-8");
Serializer serializer = SerializerFactory.getSerializer (OP);
serializer.setOutputStream(bos);
serializer.asDOMSerializer().serialize(dom);
//--- mon xml en chaine de caractères :
String s = new String( bos.toByteArray()); |
Le problème c'est que les classes utilisées font partie du package com.sun.etc... et lors de la compilation, j'ai les erreurs suivantes :
Code:
1 2 3 4 5 6 7
|
com.sun.org.apache.xml.internal.serializer.OutputPropertiesFactory is Sun proprietary API and may be removed in a future release
com.sun.org.apache.xml.internal.serializer.Serializer is Sun proprietary API and may be removed in a future release
com.sun.org.apache.xml.internal.serializer.SerializerFactory is Sun proprietary API and may be removed in a future release
com.sun.org.apache.xml.internal.serializer.OutputPropertiesFactory is Sun proprietary API and may be removed in a future release
com.sun.org.apache.xml.internal.serializer.Serializer is Sun proprietary API and may be removed in a future release
com.sun.org.apache.xml.internal.serializer.SerializerFactory is Sun proprietary API and may be removed in a future release |
J'ai trouvé sur le forum cet doc :
Citation:
Envoyé par adiGuba
Les classes de ces packages sont utiliser par la JVM pour implémenter certaines fonctionnalité, et il ne faut pas les utiliser directement pour plusieurs raisons :
- Elle n'existe pas dans les autres JVMs (IBM, Apple, etc.), et donc ton programme Java ne fonctionnera pas sur ces JVM...
- Ces classes peuvent très bien évoluer ou disparaitre même de la JVM de Sun, et donc provoquer des plantages de ton application
Donc ma question est la suivante :
Comment récupérer une chaine de craractères à partir d'un objet de type org.w3c.dom.Document sans utiliser ces classes là.
Merci d'avance