XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
This basic property of equality x = x may not hold with certain XMLSchemas

Hi Folks,

In school I learned that the square root of a number always equals the square root of the same number, e.g.,

    sqrt(9) = sqrt(9)

More generally, any value x always equals itself:

    x = x

I learned that this basic property of equality is important for mathematical reasoning. And in computer science classes I learned that it is an important property for enabling rewrite rules (replace one expression with an equivalent expression).

Below I demonstrate that the namespace of XML Schema A may not equal the namespace of the same XML Schema. That is,

    namespace(A) = namespace(A)

is not always true.

Example: The following XML Schema declares an Author element. What namespace does Author reside in?
--------------
Author.xsd
--------------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";> 
    
    <xs:element name="Author" type="xs:string" />
    
</xs:schema>

Since there is no targetNamespace, you might answer that the Author element is in "no namespace." And you would be correct, unless ...

Suppose that schema is included by this schema:

-----------
A.xsd
-----------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
                      targetNamespace="http://www.example.org";> 
    
    <xs:include schemaLocation="Author.xsd" />
        
</xs:schema>

Notice that A.xsd has a targetNamespace. By the Chameleon Effect the Author element is namespace-coerced to A's namespace. Thus, the Author element resides in the http://www.example.org namespace.

Next, suppose Author.xsd is included by this schema:

-----------
B.xsd
-----------
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
                    targetNamespace="http://www.trouble.org";> 
    
    <xs:include schemaLocation="Author.xsd" />
        
</xs:schema>

Now the Author element resides in the http://www.trouble.org namespace.

Thus, a function, namespace, when applied to the same XML Schema (Author.xsd) may produce different results. That is,

    namespace(Author.xsd)  = namespace(Author.xsd)

may not be true.

So, what are the impacts of this? At the very least, reasoning about XML Schemas which can be namespace-coerced (via the Chameleon Effect) may be challenging since a basic property of equality does not always hold. What are the other impacts? 

The only kind of XML Schemas that are subject to the Chameleon Effect are no-namespace schemas. Should it be considered Best Practice to avoid no-namespace schemas?

/Roger


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


News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS