[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
How to match targetNamespace URIs in XML Schemas to namespacedeclarations in XML instances when the targetNamespace attribute containscharacters that are illegal in URIs?
- From: Geoff Shuetrim <geoff@galexy.net>
- To: xml-dev@lists.xml.org
- Date: Thu, 3 Nov 2011 15:04:11 +1100
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\namespace".
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\namespace" 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 section 3.15.2 of the XML Schema Structures Specification (2nd edition).
The xs:anyURI data type is defined in the XML Schema Datatypes Specification (2nd edition). 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 Locator Attribute
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\namespace" 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 [RFC3986]." 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\namespace" 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]