473,574 Members | 3,151 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 8960
* 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.
--
Bjrn Hhrmann mailto:bj****@h oehrmann.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.bjoe rn.hoehrmann.de >,
Bjoern Hoehrmann <bj****@hoehrma nn.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
--
"Considerat ion 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
6380
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. And guess what, it contains utf-8 encoded characters... Now my problem is that psycopg will only accept queries of type str, so how do I get my utf-8...
3
1687
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 has invalid elements, which breaks the bulk load. I've been managing this problem by loading the document into Visual Studio and using it to...
3
2560
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 <documentcomponent>Component Part</documentcomponent> some more text </document> i.e. Embedding a tag within the contents of another tag (a la HTML)?
2
1885
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 soon as I place it inside MSIE, all that goes "bye bye". I've tried Dreamweaver, but it seems to leave the HTML in the state it found it.
38
5714
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 find an answer to this question (don't find it in the W3C_char_entities document). -- Haines Brown brownh@hartford-hwp.com
1
4632
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
5055
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). I changed the data type for the structure that contains the XML data from the default "String" to "xml.xmldocument" to enable easy filling of the...
7
12121
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, but with zero padding and hence no real conversion is necessary? If I am completely wrong and some intricate conversion operation needs to take...
2
2171
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 syntactical requirements defined by the World Wide Web Consortium (W3C) Extensible Markup Language (XML) 1.0 Recommendation, it is not considered valid unless...
4
7308
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. Initially, I was only getting them on control characters, and a little "sed -e 's/ ]/ /g' $1;" took care of that just fine. But recently, I've been getting...
0
7842
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, well explore What is ONU, What Is Router, ONU & Routers main...
0
7764
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8110
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. ...
0
8273
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7862
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...
1
5658
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...
0
3794
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2277
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1102
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...

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.