Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

strange problem - different encoding linux windows in xslt
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


Report this thread to moderator Post Follow-up to this message
Old Post
matatu
10-27-04 01:57 PM


Re: strange problem - different encoding linux windows in xslt
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
>



Report this thread to moderator Post Follow-up to this message
Old Post
Jacques Desmazieres
10-28-04 08:57 AM


Re: strange problem - different encoding linux windows in xslt
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

Report this thread to moderator Post Follow-up to this message
Old Post
matatu
10-28-04 01:58 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Java Help archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:42 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.