[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
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! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|