Article View: fr.comp.text.xml
Article #9785Probleme utilisation Xalan / Xerces en Java
From: Hugues Marilleau
Date: Mon, 05 Feb 2001 11:47
Date: Mon, 05 Feb 2001 11:47
96 lines
4424 bytes
4424 bytes
Bonjour,
voici mon probl�me :
J'utilise Xalan pour appliquer une feuille de style XSLT sur un Document
DOM dans une Servlet avec le code suivant :
import org.apache.xalan.xslt.*; // For the XLST related classes
import org.apache.xalan.xpath.xdom.*; // For XercesLiaison
...
try {
XSLTProcessor processor = XSLTProcessorFactory.getProcessor
(new org.apache.xalan.xpath.xdom.XercesLiaison ());
// Create input source documents.
XSLTInputSource xmlID = new XSLTInputSource(doc);
XSLTInputSource stylesheetID = new XSLTInputSource("test.xsl");
// Create a DOM Document node to attach the result nodes to.
Document output_doc = new org.apache.xerces.dom.DocumentImpl();
XSLTResultTarget resultTarget = new XSLTResultTarget(output_doc);
// Process the source tree and produce the result tree.
processor.process(xmlID, stylesheetID, resultTarget);
}
catch (SAXException e)
{
e.printStackTrace ();
}
"doc" est le Document de d�part, il existe et est non vide. L'application
de la stylesheet sur le contenu de doc avec Cocoon (recopie du contenu
dans un fichier .xml et appel de la m�me stylesheet dessus) donne
un r�sultat correct.
Le code java ci-dessus vient des exemples de Xalan je crois, il compile.
A l'ex�cution, une exception est lev�e, au niveau de
"processor.process ()" :
XSL Error: SAX Exception
org.apache.xalan.xslt.XSLProcessorException: XercesLiaison can not handle
nodes of type class com.sun.xml.tree.XmlDocument
at org.apache.xalan.xslt.XSLTEngineImpl.error(XSLTEngineImpl.java:1674)
at org.apache.xalan.xslt.XSLTEngineImpl.error(XSLTEngineImpl.java:1638)
at org.apache.xalan.xslt.XSLTEngineImpl.process(XSLTEngineImpl.java:671)
at Vaccination.doGet(Vaccination.java:93)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:865)
at org.apache.tomcat.core.ServletWrapper.doService
(ServletWrapper.java:404)
at org.apache.tomcat.core.Handler.service(Handler.java:286)
at org.apache.tomcat.core.ServletWrapper.service
(ServletWrapper.java:372
at org.apache.tomcat.core.ContextManager.internalService
(ContextManager.java:797)
at org.apache.tomcat.core.ContextManager.service
(ContextManager.java:743)
at org.apache.tomcat.service.connector.Ajp12ConnectionHandler.
processConnection(Ajp12ConnectionHandler.java:166)
at org.apache.tomcat.service.TcpWorkerThread.runIt
(PoolTcpEndpoint.java:416)
at org.apache.tomcat.util.ThreadPool$ControlRunnable.run
(ThreadPool.java:498)
at java.lang.Thread.run(Thread.java:475)
sur le terminal d'o� est lanc� Tomcat. (d�sol� pour la mise en page ...)
A noter que l'utilisation de DTM (avec des URL donc pour les xml de d�part
et d'arriv�e) fonctionne parfaitement.
J'utilise Tomcat 3.2, Xalan 1.2.2 et Xerces 1.2.2.
Le classpath du Tomcat contient bien
"/usr/local/jakarta-tomcat-3.2/bin/../lib/xalan.jar:
/usr/local/jakarta-tomcat-3.2/bin/../lib/xerces.jar"
Merci d'avance pour votre aide.
Ca m'embeterait d'�tre oblig� d'�crire le "doc" dans un .xml temporaire,
de r�cup�rer la sortie dans un autre .xml temporaire et de le rouvrir
pour l'afficher au client Web ...
Technical Details
Message-ID:
<slrn97t3jl.7oo.huge@xenon.medisite.net>Path:
arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!news.tele.dk!213.56.195.71!fr.usenet-edu.net!usenet-edu.net!freenix!isdnet!inetway!inetway.net!hugeShow Full Headers
Complete Article Headers
X-Google-Language: FRENCH,ASCII X-Google-Thread: 114f60,3d09a4f846f08f7,start X-Google-Attributes: gid114f60,public X-Google-ArrivalTime: 2001-02-05 03:28:56 PST Path: arc1-ca.pugleaf.net!supernews.google.com!sn-xit-02!supernews.com!news.tele.dk!213.56.195.71!fr.usenet-edu.net!usenet-edu.net!freenix!isdnet!inetway!inetway.net!huge From: huge@xenon.medisite.net (Hugues Marilleau) Newsgroups: fr.comp.text.xml Subject: Probleme utilisation Xalan / Xerces en Java Date: 5 Feb 2001 11:47:52 GMT Organization: UUNET Lines: 97 Message-ID: <slrn97t3jl.7oo.huge@xenon.medisite.net> Reply-To: hugues.marilleau@medisite.net NNTP-Posting-Host: 194.98.201.137 Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: reader1.fr.uu.net 981373672 1243 194.98.201.137 (5 Feb 2001 11:47:52 GMT) X-Complaints-To: abuse@fr.uu.net NNTP-Posting-Date: 5 Feb 2001 11:47:52 GMT X-Operating-System: Debian GNU/Linux User-Agent: slrn/0.9.6.3 (Linux)