Bonjour,

Je souhaite lancer la transformation d'un fichier xml via un fichier xslt. Seulement les exemple ne montre ceci que à partir d'un fichier. Or moi je veux créer cette transformation à partir d'un chaine qui contient le contenu du fichier.

Voici mon code sources java:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
 
//xslt est le contenu du XSLT
//xml est le contenu du XML
TransformerFactory tFactory = TransformerFactory.newInstance();
				Transformer transformer =	tFactory.newTransformer(new StreamSource(new StringReader(xslt)));
				transformer.transform(new StreamSource(new StringReader(xml)), new StreamResult(html));
Voici l'erreur renvoyer:
ERREUR : 'The processing instruction target matching "[xX][mM][lL]" is not allowed.'
ERREUR BLOQUANTE : 'Impossible de compiler la feuille de style'
javax.xml.transform.TransformerConfigurationException: Impossible de compiler la feuille de style
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(Unknown Source)
at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(Unknown Source)
at applet.Applet.afficherContenuXml(Unknown Source)
at applet.Applet$1.actionPerformed(Unknown Source)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
J'ai utiliser la classe StringReader poour créer mon Transformer à partir d'une chaine. Mais cela à l'air incorrect.

Pour info voici le contenu de mes fichiers:


--------------------------
FICHIER XML
--------------------------

Code XML : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<root>
	<personne>
		<nom>Pillou</nom>
		<prenom>Jean-François</prenom>
	</personne>
	<personne>
		<nom>VanHaute</nom>
		<prenom>Nico</prenom>
	</personne>
	<personne>
		<nom>Andrieu</nom>
		<prenom>Seb</prenom>
	</personne>
</root>
--------------------------
FICHIER XSLT
--------------------------

Code XML : Sélectionner tout - Visualiser dans une fenêtre à part
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
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/TR/REC-html40"
result-ns="">
 
	<xsl:template match="/">
		<HTML>
			<HEAD>
			</HEAD>
			<BODY BGCOLOR="#FFFFFF">
				<xsl:apply-templates/>
			</BODY>
		</HTML>
	</xsl:template >
	<xsl:template match="personne" >
		<ul>
			<li>
			<xsl:value-of select="nom"/>
			-
			<xsl:value-of select="prenom"/>
			</li>
		</ul>
	</xsl:template >
</xsl:stylesheet>


Est ce que quelqu'un aurait une idée?

Merci