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

How to match targetNamespace URIs in XML Schemas to namespacedeclaration

  • From: Geoff Shuetrim <geoff@galexy.net>
  • To: xml-dev@lists.xml.org
  • Date: Thu, 3 Nov 2011 15:04:11 +1100

How to match targetNamespace URIs in XML Schemas to namespacedeclaration
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".

I am trying to determine what the namespace declaration, for elements defined in that schema, should be when those elements are used in an XML instance document.  Specifically, should I expect:

1. xmlns="http://example.com/target%5Cnamespace" or should I expect
2. xmlns="http://example.com/target%5Cnamespace"

The targetNamespace attribute in an XML schema has the xs:anyURI datatype.  This is based on http://www.w3.org/TR/xmlschema-1/#declare-schema.

The xs:anyURI data type is defined in http://www.w3.org/TR/xmlschema-2/#anyURI. That definition includes a mapping from the xs:anyURI value to the implied URI reference.  The mapping is defined by the URI reference escaping procedure defined in Section 5.4 http://www.w3.org/TR/2001/REC-xlink-20010627/#link-locators of the XLink 1.0 Specification, suggesting that the backslash, which is illegal  in a URI (see http://www.ietf.org/rfc/rfc3986.txt), must be replaced with the percent-encoding for that character (%5C) to obtain the URI reference implied by the targetNamespace attribute value.  This means that "http://example.com/target%5Cnamespace" is a valid targetNamespace.

So, what to expect for the namespace declaration in the XML instance?  The XML Namespace specification (see http://www.w3.org/TR/xml-names/#concepts) interprets the value in the xmlns attribute as a URI reference.  There is no discussion of any XLink-spec. style mapping to a URI reference from some other string of characters.  Note, though, that the XML Namespaces specification also states (in http://www.w3.org/TR/xml-names/#ProcessorConformance) that "To conform to this specification, a processor MUST report violations of namespace well-formedness, with the exception that it is not REQUIRED to check that namespace names are URI references http://www.w3.org/TR/xml-names/#URIRef."  I am not absolutely sure what that means, but it might be interpreted as saying that a namespace declaration that uses a URI reference with invalid syntax might be overlooked by a processor that implements the XML Namespace specification.

So much for the specifications.  All of the XML Schema validation tools that I have experimented with have insisted that the namespace declaration in the instance be "http://example.com/target%5Cnamespace" if they are going to associate the XML Schema with the elements in that namespace.

Any pointers to past threads that have clarified what is the right way to handle this kind of targetNamespace situation would be appreciated.  Also, if people know of specific tests in the XML Schema conformance tests that address this, that would be very helpful.  Nothing leapt out at me when I grepped for likely candidates.

Regards

Geoff Shuetrim


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