OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   XML Schemas: elementFormDefault - to qualify or not?

[ Lists Home | Date Index | Thread Index ]
  • From: "Roger L. Costello" <costello@mitre.org>
  • To: xml-dev@lists.xml.org
  • Date: Sat, 15 Jul 2000 10:22:09 -0400

Hi Folks,

I am still struggling with when to use elementFormDefault="qualified"
versus elementFormDefault="unqualified".  The answer to the
following question will provide great insight into which one
to use.

Consider this schema:

<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/1999/XMLSchema"
        targetNamespace="http://www.publishing.org"
        elementFormDefault="qualified"
        xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
        xsi:schemaLocation=
                        "http://www.w3.org/1999/XMLSchema
                         http://www.w3.org/1999/XMLSchema.xsd">
    <element name="BookCatalogue">
        <complexType>
             <sequence>
                 <element name="Book" maxOccurs="unbounded">
                     <complexType>
                         <sequence>
                             <element name="Title" type="string" 
                                      minOccurs="1" maxOccurs="1"/>
                             <element name="Author" type="string"
                                      minOccurs="1" maxOccurs="1"/>
                             <element name="Date" type="string"
                                      minOccurs="1" maxOccurs="1"/>
                             <element name="ISBN" type="string"
                                      minOccurs="1" maxOccurs="1"/>
                             <element name="Publisher" type="string"
                                      minOccurs="1" maxOccurs="1"/>
                         </sequence>
                     </complexType>
                 </element>
            </sequence>
        </complexType>
    </element>
    <element name=Title" type="uriReference"/>
</schema>

Things to note about this schema:

1. elementFormDefault="qualified".  Thus, in an instance document
   all the elements must be qualified.  Another way of looking at
   this is that _all_ the elements declared in the schema are in
   targetNamespace (even the local elements).

2. There are two Title elements: one of type string, the other of
   type uriReference.  The string Title is a local element while
   the uriReference Title is a global element.

Here's my question:

Suppose that I have an application which wishes to reference the
Title element from the http://www.publishing.org namespace (this
is the namespace defined by our schema above).
Which Title will be referenced - the string Title or
the uriReference Title?  The elementFormDefault="qualified" indicates
that both Titles are "in the namespace", so it is not at all clear
to me which Title will be referenced.  

Speculation:

1. Perhaps it's one of those cases where it's ambiguous which Title is
being referenced and hence it's illegal? 
If that's the case then it should be a rule in the spec that
elementFormDefault _must_ be assigned "unqualified" whenever the schema
has multiple elements with the same name, and it's illegal to do
otherwise.  As far as I know, there is no such rule.  Perhaps there
should be?

2. Another possibility is that elementFormDefault="qualified" doesn't
really put all the elements in the namespace.  Only the global elements
really are in the namespace.  Thus, the application refers to the
uriReference (global) Title.  However, I have a problem with this
because elementFormDefault="qualified" requires that in an instance
document we _must_ qualify all elements, which clearly indicates that
all the elements are in the namespace.  Hence if this possibility is
true then the instance document is effectively stating "make it look
like the elements are all in the namespace (by qualifying them all), but
they're not really. We're just pretending".

Can anyone shed some light on this?  Thanks. /Roger





 

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

Copyright 2001 XML.org. This site is hosted by OASIS