• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XSLT and unicode

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi.
I'm using java servlets which use XSL files to convertXML data into html (xalan and xerces packages).
It works fine with regular ascii based files, but when I use a file saved in a UTF-8 encoding, I
get a non ascii character at the begining of the
XSL doc. even if I remove this character, the non ascii characters display in the browser as question marks.
The code:
XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
XSLTInputSource input = new XSLTInputSource(document);
InputStreamReader ir = new InputStreamReader(new FileInputStream(filePath),"UTF8");

XSLTInputSource styleSheet = new XSLTInputSource(ir);
Writer out = response.getWriter();
response.setContentType("text/html");
PrintWriter output = new PrintWriter(out ,true);
processor.process(input, styleSheet, new XSLTResultTarget(output));

Does anyone have an idea?
 
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The browser does not understand UTF8 unless you set
it to use that encoding. Communicator 4.7 for Win32
has the setting under View->Character Set. Other
browsers are probably configurable, too.
How do you know the file is saved as UTF8? If you
look at the result file with the same application
that you use to create the input file, do you still
see the extra character?
HTH,
Joe
 
High Plains Drifter
Posts: 7289
Netbeans IDE VI Editor
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yoav, please change your display name to conform to JavaRanch's naming policy.
Thanks for your cooperation,
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic