[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Original encoding lost after transformation

Subject: Re: Original encoding lost after transformation
From: David Carlisle <davidc@xxxxxxxxx>
Date: Fri, 18 Feb 2005 11:30:58 GMT
java.io.utfdataformatexception invalid byte
The encoding of the source file is interpreted by the XML parser which
just reports unicode character positions in an encoding neutral way so
xslt doesn't have any record of the original encoding.

You can ask that it outputs in latin 1 by going
<xsl:output encoding="iso-8859-1"/>

Note however that every XML application has to accept utf8 but support
for iso-8859-1 is an optional feature so (in theory at least) your
resulting document will be less portable.

You say you got:

  Some transformations (depending on the source xml) now fail on the
  second pass as the first pass returns data with the wrong UTF-8 declaration
  above. The error message is:
  
  java.io.UTFDataFormatException: Invalid byte 2 of 2-byte UTF-8 sequence

It's most unlikely that XSLT writes out a file with a bad encoding
declaration so this is probably an indication of another error
somewhere in your processing chain.

Note that if you are doing two transformations back to back from java
(or any other similar API)  you almost certainly should not be encoding
and decoding the intermediate stage at all. Most XSLT processors will
allow you to pass the result tree of the first transform directly to the
second transform without having to serialise it in some encoding and
then re-parse it.

David


________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.