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

Poor interoperability due to ambiguity of which has precedence: XML enco

  • From: "Costello, Roger L." <costello@mitre.org>
  • To: "xml-dev@lists.xml.org" <xml-dev@lists.xml.org>
  • Date: Thu, 19 Dec 2013 10:29:33 +0000

Poor interoperability due to ambiguity of which has precedence: XML enco
Hi Folks,

The encoding of an XML document can be specified:

1. In the XML declaration
2. In an HTTP charset header field (if the XML document is being transported via HTTP)
3. In the BOM

Suppose the BOM of an XML document indicates that each character in the XML document uses 2 bytes but the XML declaration specifies UTF-8. Applications must resolve this ambiguity. The problem is that every application resolves it differently. Hence, there is poor interoperability.

How should this ambiguity be resolved?

Here is one approach:

	In cases where conflicting information is 
	supplied (from charset param, BOM and/or 
	XML encoding declaration) give the BOM, if
	present, authoritative status.

Martin J. D�� responded:

	I'm a bit uneasy about the fact that we now 
	have BOM (internal) - charset (external) - 
	encoding (internal), i.e. internal-external-internal, 
	but I guess there is lots of experience in HTML 5 
	for giving the BOM precedence. Also, it will be 
	extremely rare to have something that looks like 
	a BOM but isn't, and this combined with the fact 
	that XML balks on encoding errors should make 
	things quite robust.

This recommendation has been proposed:

	Recommend against the use of UTF-32.

Martin J. D�� responded:

	UTF-32 has some (limited) appeal for internal 
	representation, but none really on the network, 
	and media types are for network interchange, so 
	this should be fine, too.

Leif Halvard Silli responded to Martin J. D��:

> I'm a bit uneasy about the fact that we now have BOM (internal) - 
> charset (external) - encoding (internal), i.e. 
> internal-external-internal,

A better way of looking at would be that we now get External-Internal, where external is subdivided in charset parameter and encoding signature 
[BOM]. And internal is subdivided in encoding declaration and 
default/fallback encoding. Yeah, it might be that a lack of clear 
classification of the BOM as an external method is quite directly 
linked to the lack of interoperability. 

Previously we had External-Limbo-Internal. However, per XML, both BOM 
and charset param are external.[1] 

> but I guess there is lots of experience 
> in HTML 5 for giving the BOM precedence.

Sorry for focusing on XML rather than XML media types, but I think both 
of them should be edited.

The way of looking at it that I propose above also incorporates the 
fact that XML-capable Web browsers (the HTML 5 browsers) give 
precedence to the BOM, and without fatal error if there is a 
(conflicting) XML encoding declaration. (BTW, I find it very odd that, 
up until now, the *charset* parameter could override the encoding 
declaration, but if the BOM does the same [that is: overrides the 
encoding declaration], *then* it is a fatal error ...)

It makes sense to treat all external encoding declaration methods the 
same. Currently only the external *transport* protocol may override the 
internal mechanism. But the BOM should have the same "right".

Therefore I would suggest that the other spec, XML 1.0, section 4.3.3 
[2] does this (see the <INS> element):

	In the absence of information provided by an 
	external transport protocol (e.g. HTTP or MIME) 
	<INS>OR BY THE BYTE ORDER MARK</INS>, it 
	is a fatal error for an entity including an encoding 
	declaration to be presented to the XML processor 
	in an encoding other than that named in the declaration.

It should still be an error, but not a fatal error, if the XML encoding 
declaration  conflicts with the external method - BOM or HTTP.

QUESTION

How do you recommend dealing with the situation where the BOM, charset, and XML encoding are conflicting?

/Roger

[1] http://www.w3.org/TR/REC-xml/#NT-document
[2] http://www.w3.org/TR/REC-xml/#charencoding


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.