Code Comments
Programming Forum and web based access to our favorite programming groups.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
Post Follow-up to this messageTry 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 >
Post Follow-up to this messageHi 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
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.