473,758 Members | 5,909 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

trans.transform (xmlSource, htmlResult) fails

rob
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.tran sform.Transform erException):
java.io.UTFData FormatException : Invalid byte 1 of 1-byte UTF-8
sequence.

when executing

java org.apache.xala n.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
=============== =============
<xsl:output 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

May 5 '06 #1
4 1433


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.tran sform.Transform erException):
java.io.UTFData FormatException : 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/
May 5 '06 #2
rob
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,

May 5 '06 #3


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/
May 5 '06 #4
rob
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.getPrett yFormat();
format.setEncod ing("ISO-8859-1");
XMLOutputter outputter = new XMLOutputter(fo rmat);
outputter.outpu t(document, new FileWriter( new File("cent.xml" ) );

May 5 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1429
by: annoyed tuna | last post by:
I was wondering if someone could help me out. I'm trying to perform an XSL transformation on an XML document that uses entities. While I can do XSLT on a file without entities, it all falls apart when I try and add an entity. Here are my files... -----TEST.XML------ <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="test.xsl"?> <!DOCTYPE document >
2
1024
by: John Lehmann | last post by:
I have an interesting problem. I am performing an XSL transform using the System.Xml.Xsl.Transform class. I have a database that contains the XSL style sheet string. And it seems to work pretty well for simple transforms. But as soon as I add Xsl variables or For each loops to the XSL string in the db, it fails to transform the XML. I can see that it will transform everything until that point. ALso If I copy the XSL & XML I am trying to...
4
1748
by: Peter Row | last post by:
Hi, I have 2 XML files and 1 XSLT file. The second XML file has the following declarative 1st line: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> ....the 1st one (the one to be transformed) doesn't. In the transform file I load the 2nd XML file which contains
5
5223
by: John Sever | last post by:
My transform in cludes a variable that holds a node set from the node-set() extension function. It the transformation works fine when using MSXML2 or msxsl.exe but not in VB.Net. My code looks something like this: Dim XP as New XPathDocument(XMLFileName) Dim XSLT as New XslTransform XSLT.Load(XSLTFileName) Dim Out as New MemoryStream
3
2478
by: Jason S | last post by:
Hello Group, I am just about tearing my hair out with this one and thought someone may have some insight. I have a transform that wasn't working so I grabbed the nearest debugger (xselerator) and saw that it works just fine. Now what I mean by not working is that it just silently fails to produce the expected output... no exceptions are being thrown. Xselerator uses msxml 3 so it's not really helping me see the problem in .net 1.1. ...
2
2152
by: Greg Merideth | last post by:
I have an XSL file that I am using to transform some XML data using this method below. The problem is that if I use an embedded .XSL file in the .NET assembly, I get an error indicating that the URI is invalid, however if I open the file from the harddrive in the current directory, it works. Here's the method, notice that after s is loaded with the .xsl file from the resource stream that if you do a messagebox.show with s.readtoend you...
6
2656
by: Pete Verdon | last post by:
Summary: Can I do an XSLT transform, in the client, of a tree of nodes taken from the displayed page DOM in IE? This works in Firefox. Hi, I'm just starting the process of rewriting part of a "database frontend" type of intranet application. The existing table-display code consists of a mountain of very clever but extremely brittle spaghetti-javascript, which I'm planning to replace with XSLT transformations. At present I'm still...
19
3251
by: Taras_96 | last post by:
Hi all, A poster at http://bytes.com/forum/thread60652.html implies that using strtoupper in transform doesn't work because ctype.h may define strtoupper as a macro: "The problem is that most implementations of the standard C <ctype.h> header define functions like toupper/tolower/etc as macros. To make it work in STL algorithms, you have to include <cctypeheader instead of <ctype.h>. At least on my PC (Debian/gcc 3.3),...
3
5236
by: =?Utf-8?B?S2VuIExlbWlldXg=?= | last post by:
My clickonce app fails when the install button on the publish.htm page is clicked. User is prompted with a "Cannot Start Application" dialog. Details provided from the dialog are: PLATFORM VERSION INFO Windows : 5.1.2600.196608 (Win32NT) Common Language Runtime : 2.0.50727.3053 System.Deployment.dll : 2.0.50727.3053 (netfxsp.050727-3000) mscorwks.dll : 2.0.50727.3053 (netfxsp.050727-3000)
0
9489
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10072
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9885
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9737
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7286
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5172
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3399
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2698
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.