Bonjour,
J'ai trouvé dans ce forum bon nombre de sujets relatifs aux accents dans les transformations xsl mais je ne suis pas arrivée à résoudre mon problème malgré tout.
Le fait est que j'extrais un texte de ma BDD et lorsque je veux le transformer, les accents ne passent pas (exemple : "è" => "è").
Voici mon code, "texte" contient le texte issu de ma BDD. (en l'occurance "Cet après-midi :")
"resultat" contient alors "Cet après-midi :"
Code : 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
26
27
28
29
30
31
32
33
34
35
36
37
38 String resultat = new String(); TransformerFactory transformerFactory = TransformerFactory.newInstance(); String pathXSL="\test.xsl"; StreamSource sourceXSL = null; sourceXSL = new StreamSource(pathXSL); Transformer transformer; try { transformer = transformerFactory.newTransformer(sourceXSL); ByteArrayInputStream sourceStream =null; sourceStream = new ByteArrayInputStream(texte.getBytes()); StreamSource sourceXML = new StreamSource(sourceStream); StringWriter writer = new StringWriter(); StreamResult result = new StreamResult(writer); transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1"); transformer.setOutputProperty(OutputKeys.METHOD, "html"); transformer.transform(sourceXML,result); resultat=writer.toString(); }catch (TransformerConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (TransformerException e) { // TODO Auto-generated catch block e.printStackTrace(); } return resultat;
Et voici l'entete de mon fichier xsl :
Merci d'avance pour votre aide.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5 <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="xml" encoding="ISO-8859-1" omit-xml-declaration="no" indent="yes"/>
Partager