473,395 Members | 1,468 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

XML not well formed and UTF-8 encoding

Hi
I am pretty new to XML and I am struggling validating this XML:
<?xml version="1.0" encoding="UTF-8"?>
<XML>×</XML>

This is a (very limited) extract of a huge file we receive from one of
our partners.

My validation tool (and parser!) says this is not a well formed XML
because of the multiplication sign - hexa D7.
As it is encoded in UTF-8, I can't see why some characters would be
refused... I must say I am really confused...

Any help ?
many thanks in advance

Jan 19 '07 #1
8 8952
* Philou59 wrote in comp.text.xml:
>I am pretty new to XML and I am struggling validating this XML:
<?xml version="1.0" encoding="UTF-8"?>
<XML>×</XML>

This is a (very limited) extract of a huge file we receive from one of
our partners.

My validation tool (and parser!) says this is not a well formed XML
because of the multiplication sign - hexa D7.
As it is encoded in UTF-8, I can't see why some characters would be
refused... I must say I am really confused...
The lone sequence 0xD7 cannot occur in a UTF-8 encoded document. If it
really does occur like that, then the document is not UTF-8 encoded and
therefore not well-formed XML. You should contact whoever sends you the
document like this, and have them fix it.
--
Björn Höhrmann · mailto:bj****@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
Jan 19 '07 #2
Philou59 schrieb:
Hi
I am pretty new to XML and I am struggling validating this XML:
<?xml version="1.0" encoding="UTF-8"?>
<XML>×</XML>
May not be related to your problem, but...
<http://www.w3.org/TR/REC-xml/#dt-name>:
[Definition: A Name is a token beginning with a letter or one of a few
punctuation characters, and continuing with letters, digits, hyphens,
underscores, colons, or full stops, together known as name characters.]
Names beginning with the string "xml", or with any string which would
match (('X'|'x') ('M'|'m') ('L'|'l')), are reserved for standardization
in this or future versions of this specification.

--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)
Jan 19 '07 #3
Philou59 wrote:
Hi
I am pretty new to XML and I am struggling validating this XML:
<?xml version="1.0" encoding="UTF-8"?>
<XML>×</XML>

This is a (very limited) extract of a huge file we receive from one of
our partners.

My validation tool (and parser!) says this is not a well formed XML
because of the multiplication sign - hexa D7.
As it is encoded in UTF-8, I can't see why some characters would be
refused... I must say I am really confused...

Any help ?
many thanks in advance
http://unicode.org/unicode/faq/utf_bom.html#15

--
Cordialement,

///
(. .)
--------ooO--(_)--Ooo--------
| Philippe Poulard |
-----------------------------
http://reflex.gforge.inria.fr/
Have the RefleX !
Jan 19 '07 #4

Bjoern Hoehrmann wrote:
You should contact whoever sends you the
document like this, and have them fix it.
It's a mistake to validate invalidate documents, even when they're
exchanged between businesses. Take this issue up with the provider of
the document and have them fix it, where it ought to be fixed. If it's
not XML, it's not XML. If it's unpredictably case-insensitive,
unbalanced, misses quotes, insists on particular quote characters, uses
HTML entities or is otherwise broken, then they're just not doing XML,
no mattter how much their pointy-headed conslutant claims they are.

I know this approach is unpopular, especially with your bosses' boss.
If you start applying work-arounds though, the whole thing becomes
increasingly unmaintainable. Just don't go there, whatever the
commercial problem in sorting it out properly.

I can't remember how many times I've gone down this route 8-(

Jan 19 '07 #5
<?xml version="1.0" encoding="UTF-8"?>
<XML>×</XML>
If you're going to use XML, you have to honor XML's rules. If you don't,
it isn't XML, period.

As others have said, first thing to do is to rename that element to
something other than XML.

As far as the character being illegal: Not all characters are permitted
in XML; see the spec, available from the W3C's website. XML 1.1 permits
many characters that XML 1.0 didn't, but that requires that the document
be marked as being 1.1 (yours explicitly says 1.0) and requires that
everyone working with the document use tools that support 1.1.

Even in 1.1, I believe some characters are reserved. The traditional
workaround if you really need unconstrained binary data is the same one
used in e-mail: encode the data (typically as base-64) and make
converting it between the encoded form and the actual form the
application's responsibility.


>
May not be related to your problem, but...
<http://www.w3.org/TR/REC-xml/#dt-name>:
[Definition: A Name is a token beginning with a letter or one of a few
punctuation characters, and continuing with letters, digits, hyphens,
underscores, colons, or full stops, together known as name characters.]
Names beginning with the string "xml", or with any string which would
match (('X'|'x') ('M'|'m') ('L'|'l')), are reserved for standardization
in this or future versions of this specification.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Jan 19 '07 #6
(And, as others have suggested, you should probably also doublecheck the
UTF-8 encoding rules to make sure you're expressing that character
correctly. Even if it's legal XML, UTF-8 may require that it be encoded
as multiple bytes.)

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Jan 19 '07 #7
In article <bq********************************@hive.bjoern.ho ehrmann.de>,
Bjoern Hoehrmann <bj****@hoehrmann.dewrote:
>The lone sequence 0xD7 cannot occur in a UTF-8 encoded document. If it
really does occur like that, then the document is not UTF-8 encoded and
therefore not well-formed XML. You should contact whoever sends you the
document like this, and have them fix it.
Most likely, they have made a mistake with the labelling. Perhaps the
data is in fact in ISO Latin-1. Did your supplier put the declaration
at the top or did you?

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Jan 19 '07 #8
Joe Kesselman wrote:
Philou59 wrote in comp.text.xml:
>>I am pretty new to XML
So, I think, are your partners.
><?xml version="1.0" encoding="UTF-8"?>
<XML>�</XML>
0xD7 is a multiplication sign in ISO-8859-1 (and a few others). In UTF-8
it's 0xC397. Either your partners' system is falsifying the encoding of
the document, or their software is crocked.
If you're going to use XML, you have to honor XML's rules. If you don't,
it isn't XML, period.
Yep. If people send you invalid documents, send them straight back and
ask for valid ones. Sometimes you have to hit them with a lart first.
This includes partners.
Even in 1.1, I believe some characters are reserved.
Not reserved, forbidden :-)

///Peter
--
XML FAQ: http://xml.silmaril.ie
Jan 20 '07 #9

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

Similar topics

4
by: Alban Hertroys | last post by:
Another python/psycopg question, for which the solution is probably quite simple; I just don't know where to look. I have a query that inserts data originating from an utf-8 encoded XML file....
3
by: Ken Fine | last post by:
I periodically receive a 5+ MB XML document that I hand-load into SQL Server using SQLXML running under a DTS process. Unfortunately, the document is human-created, and (very unfortunately) often...
3
by: Paul Flew | last post by:
Hi I'm sure this is a very simple question, but can someone tell me whether the following is a well-formed XML document (not withstanding the lack of DTD): <document>Some text...
2
by: Gadrin77 | last post by:
is there a tool that'll take HTML and "parse it" and create a well-formed HTML document? the reason I ask is that I have scripts and XSL files that of course create well-formed HTML, but as...
38
by: Haines Brown | last post by:
I'm having trouble finding the character entity for the French abbreviation for "number" (capital N followed by a small supercript o, period). My references are not listing it. Where would I...
1
by: Ashish | last post by:
Hi Are there any functions in .Net which can be used to verify whether xml is well formed? Thanks, Ashish
3
by: Jerome Cohen | last post by:
AI am trying to call a third-party web service. this service expects an XML fragment that contains the request plus other parameter. adding the web reference created the syntax below(reference.vb)....
7
by: Jimmy Shaw | last post by:
Hi everybody, Is there any SIMPLE way to convert from UTF-16 to UTF-32? I may be mixed up, but is it possible that all UTF-16 "code points" that are 16 bits long appear just the same in UTF-32,...
2
by: Arpan | last post by:
I came across the following statement at http://windowssdk.msdn.microsoft.com/en-us/library/hdf992b8.aspx: Although an XML document is considered to be well formed if it meets all the...
4
by: jvictor118 | last post by:
I've been using the xml.sax.handler module to do event-driven parsing of XML files in this python application I'm working on. However, I keep having really pesky invalid token exceptions....
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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...

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.