Home > Archive > Java Help > October 2004 > strange problem - different encoding linux windows in xslt
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
strange problem - different encoding linux windows in xslt
|
|
| matatu 2004-10-27, 8:57 am |
| Hi to all,
my program java applies some trasforms xslt to a file xml using the
attribute encoding = "ISO-8859-1": it work fine under windows xp, but if
I run the program on a pc with redhat ES the file output it contains '?'
to the place of the accented characters...
I apply the trasforms like following:
tFactory = TransformerFactory.newInstance();
transformer = tFactory.newTransformer(new
javax.xml.transform.stream.StreamSource(arrayXslt[0]));
transformer.transform(new
javax.xml.transform.stream.StreamSource(finput),new
javax.xml.transform.stream.StreamResult (new
FileOutputStream(arrayOut[0])));
I hope to have been clear...
thank you for any suggestion
Mark
| |
| Jacques Desmazieres 2004-10-28, 3:57 am |
| Try to use the writer specify explicitely the encoding:
javax.xml.transform.stream.StreamResult (new OutputStreamWriter(new
FileOutputStream(arrayOut[0]), "ISO-8859-1")));
I did not test this piece of code but this should do what you need
Jacques Desmazieres
"matatu" <mar0as@katamail.com> a écrit dans le message de news:
clo45n$lvd$2@lacerta.tiscalinet.it...
> Hi to all,
>
> my program java applies some trasforms xslt to a file xml using the
> attribute encoding = "ISO-8859-1": it work fine under windows xp, but if
> I run the program on a pc with redhat ES the file output it contains '?'
> to the place of the accented characters...
>
> I apply the trasforms like following:
>
> tFactory = TransformerFactory.newInstance();
> transformer = tFactory.newTransformer(new
> javax.xml.transform.stream.StreamSource(arrayXslt[0]));
> transformer.transform(new
> javax.xml.transform.stream.StreamSource(finput),new
> javax.xml.transform.stream.StreamResult (new
> FileOutputStream(arrayOut[0])));
>
> I hope to have been clear...
>
> thank you for any suggestion
> Mark
>
| |
| matatu 2004-10-28, 8:58 am |
| Hi Jacques,
I have found the root of the problem: when I parse the file xml with
SAXParse and I get the text with metod characters...
this is my code:
XMLReader xmlrd = XMLReaderFactory.createXMLReader(PARSER_NAME);
xmlrd.setContentHandler(oggetto);
xmlrd.parse("myxml.xml");
// I have tried also:
//xmlrd.parse(new InputSource(new InputStreamReader(new
//FileInputStream("myxml.xml"),"ISO8859_1")));
PS: myxml.xml already contains a declaration <?xml version="1.0"
encoding="ISO-8859-1"?>
where oggetto class has:
public void characters(char[] ch, int start, int length) throws SAXException
{
String unrectmp="";
if(inrec)
{
if (ch[start] != '\n')
{
for (int i = start; i < start + length; i++)
{unrectmp += ch[i];}
System.out.println(ch[i]);
unrec += unrectmp;
}
}
}
thanks for possible answer...
Mark
Jacques Desmazieres ha scritto:
> Try to use the writer specify explicitely the encoding:
>
> javax.xml.transform.stream.StreamResult (new OutputStreamWriter(new
> FileOutputStream(arrayOut[0]), "ISO-8859-1")));
>
> I did not test this piece of code but this should do what you need
>
> Jacques Desmazieres
|
|
|
|
|