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

Re: How to match targetNamespace URIs in XML Schemas tonamespa

  • From: Michael Kay <mike@saxonica.com>
  • To: xml-dev@lists.xml.org
  • Date: Fri, 04 Nov 2011 10:51:18 +0000

Re:  How to match targetNamespace URIs in XML Schemas tonamespa
On 03/11/2011 04:04, Geoff Shuetrim wrote:
CAB13hhaNbQz+e7qSpE+S3LWxfPkswh_UPoR3HCrCd=gPFBZTQA@mail.gmail.com" type="cite">I have come across an XML Schema document with a targetNamespace attribute that contains, among other characters, a backslash character, for example "http://example.com/target%5Cnamespace".

The XML specifications, taken as a whole, are hopelessly muddled about the exact rules on whether namespace names have to be valid URIs, whether leading and trailing whitespace is ignored, and other such details. For example the conformance section of the Namespaces 1.0 specification says nothing on the subject [ http://www.w3.org/TR/REC-xml-names/#Conformance ]

though the phrase

Definition: A document is namespace-well-formed if it conforms to this specification.

is capable of being read many ways, one of which is as a tautological self-reference.

The spec does say "[Definition: An XML namespace is identified by a URI reference [RFC3986]... ]", but it nowhere has any kind of "MUST", and I believe the omission is deliberate because I raised the point while the spec was still in draft and the WG responded saying they had decided to do nothing. So I believe the situation is that the use of an invalid URI in a namespace declaration does not prevent the document being namespace-well-formed.

There are other specs that do require namespace names to be legal URIs, for example the Infoset and the Canonicalization spec. Other specs such as XSD and XSLT/XQuery simply get caught in the crossfire.

The best advice one can give is therefore to apply Postel's law: when you have the choice, always use a valid URI, but when you are accepting input from others, accept any string of characters (and compare them 'as is', perhaps after trimming leading and trailing whitespace).

XSD 1.1 has taken this route by allowing any sequence of characters to appear in an xs:anyURI value, and by clarifying that the mapping from the lexical space to the value space is one-to-one. (XSD 1.0 had the awful statement "Thus in practice the above definition imposes only very modest obligations on ·minimally conforming· processors [to check the value].", without offering any clear guidance on what those obligations are.)

Michael Kay
Saxonica




[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.