Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > trans.transform(xmlSource, htmlResult) fails

Reply
Thread Tools

trans.transform(xmlSource, htmlResult) fails

 
 
rob
Guest
Posts: n/a
 
      05-05-2006
Hi all, I have some xml that has the cent character in it
( not sure it it will post but here it is -> )

I get this error

(Location of error unknown)XSLT Error
(javax.xml.transform.TransformerException):
java.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8
sequence.

when executing

java org.apache.xalan.xslt.Process -IN cent.xml -XSL cent.xsl -OUT
cent.html

anyhow, I am trying to use

my cent.xml is
********************************************
<?xml version="1.0" encoding="UTF-8"?>
<EMAIL>
<L>10</L>
</EMAIL>
*********************************************
my cent.xsl is
============================
<xslutput method="html"/>
<xsl:template match="/">
<html>
<body>
<xsl:value-of select="/EMAIL/L"/>

</body>
</html>
</xsl:template>
</xsl:stylesheet>
=============================

I think is has to do with the encoding because if I change my
encoding="UTF-8" to encoding="ascii" in my xml
I generates the html (but it did not convert the cent char properly,
but at least no error)

thanks for any help

 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      05-05-2006


rob wrote:

> Hi all, I have some xml that has the cent character in it
> ( not sure it it will post but here it is -> )
>
> I get this error
>
> (Location of error unknown)XSLT Error
> (javax.xml.transform.TransformerException):
> java.io.UTFDataFormatException: Invalid byte 1 of 1-byte UTF-8
> sequence.


Sounds like the XML claims it is UTF-8 encoded but it is not, rather
that cent symbol is encoded as one byte.
So make sure that the XML correctly declares its encoding e.g.
<?xml version="1.0" encoding="ISO-8859-1"?>




--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
 
 
 
rob
Guest
Posts: n/a
 
      05-05-2006
Martin, thank you so much, I am a bit weak on the xml conversion
stuff, so I didn't know where to turn, thanks for taking the time
to reply, I really appreciate it, it works great.


will changing
<?xml version="1.0" encoding="UTF-8"?>
to
<?xml version="1.0" encoding="ISO-8859-1"?>

break any transformations that you know of?
Typically the fiels I am transforming do not have the
extended chars like the cent char,

 
Reply With Quote
 
Martin Honnen
Guest
Posts: n/a
 
      05-05-2006


rob wrote:


> will changing
> <?xml version="1.0" encoding="UTF-8"?>
> to
> <?xml version="1.0" encoding="ISO-8859-1"?>
>
> break any transformations that you know of?
> Typically the fiels I am transforming do not have the
> extended chars like the cent char,


The suggestion is more an example on what you could change. I don't know
whether ISO-8859-1 is the encoding the author of the XML has used. So
what you really need to do is declare the encoding you or someone else
uses when creating the XML.



--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
rob
Guest
Posts: n/a
 
      05-05-2006
I have a byte array I get from the DB then convert it to a string,
and I create the XML via JDOM from this string,
then transform the JDOM dom , so I can call the format method
with any encoding I choose,

but the underlying byte array has the cent char
and when I left my generated xml encoded via UTF-8, it threw the error,
but this works if I convert the

here is where i dump the xml to the file system after I have already
create a JDom document object from the DB

Format format = Format.getPrettyFormat();
format.setEncoding("ISO-8859-1");
XMLOutputter outputter = new XMLOutputter(format);
outputter.output(document, new FileWriter( new File("cent.xml") );

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Constant.t fails 240 of 272 tests and recurs.t fails 1 of 25 tests on HPUX using perl 5.8.7 dayo Perl Misc 11 12-16-2005 09:09 PM
slideshow fails, Firefox debugger also fails lkrubner@geocities.com Javascript 2 12-23-2004 06:22 PM
Wireless Zero Configuration Servoce fails to start andrew Wireless Networking 0 07-28-2004 03:08 PM
IAS fails with certs from Stand Alone CA Harrison Midkiff Wireless Networking 2 07-22-2004 09:45 PM
Forms Authentication Fails Between ASP.NET 1.0 and 1.1 Applications (Cookie Decryption Fails) John Saunders ASP .Net 1 11-18-2003 03:25 PM



Advertisments