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


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: XML Schemas: Best Practices

Thanks for all your comments Jeff.  Let me try to reply to your
questions.  [Note: this week I feverishly working on summarizing all
these issues and posting them on my web site.  I hope to have it
completed by Friday.]

> > <?xml version="1.0"?>
> > <schema xmlns="http://www.w3.org/2000/10/XMLSchema"
> >         targetNamespace="http://www.library.org"
> >         xmlns:lib="http://www.library.org"
> >         elementFormDefault="qualified">
> >     <include schemaLocation="BookCatalogue.xsd"/>
> >     <element name="Library">
> >         <complexType>
> >              <sequence>
> >                  <element name="BookCatalogue">
> >                      <complexType>
> >                          <sequence>
> >                              <element ref="lib:Book"
> >                                 minOccurs="0" 
> >                                 maxOccurs="unbounded"/>
> >                          </sequence>
> >                      </complexType>

> Should there be a closing element tag here?  I don't think this is 
> important for sake of the example-- only if this exact example is
> published as a Best Practice.  (The WF error also occurs in 
> Approach 2).

Thanks, I'll make certain that the online version is correct.

> > Before describing why I believe that approach 2 is better, we 
> > need to first revisit Chameleon components.
> >
> > Components that are in a schema with no targetNamespace have a very
> > interesting property: when they are <include>d in a schema that has 
> > a targetNamespace then those no-namespace components take on the 
> > namespace of the <include>ing schema.  They "blend into the 
> > background" just like a Chameleon.  Thus, the no-namespace 
> > components are called Chameleon components.
> >
> > In the above schemas there is an <include> element to bring in the
> > components in BookCatalogue.xsd.  Let's consider how the above
> > approaches behave when the schema being <include>d 
> > (BookCatalogue.xsd) has no namespace.  Here is BookCatalogue.xsd:
> Wow, what a great description.  Do you happen to have any other 
> references for this?  

Thanks! Yes, we discussed the Chameleon design approach quite a bit in
the Zero, One, or Many Namespaces issue.  See: 


> It seems as though stuff like this may in fact affect other Best
> Practices or decisions therein.  This also seems like a good one for 
> the Schema FAQ-- What is a chameleon component?

A Chameleon component is a component (element, simpleType, complexType,
attribute, attributeGroup, or modelGroup) in a no-namespace schema. 
They are called "Chameleon" because they have the property of taking on
the namespace of a schema which <include>s them (just like a Chameleon
animal is able to blend into its surroundings)  (Good question Jeff, I
have never explicitly defined this.  Thanks.)
> (are you going to give a prefix as best practice? e.g. "xsd:" 
> <ducks/>)--

Uh, no (but I like xsd).
> Is there an Approach 3? (a.k.a. is this even right?)

Yes, good point.  I forgot about that.  As you mention, Approach 3 is to
have no default namespace, and explicitly qualify everything.  Below is
shown this approach:

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2000/10/XMLSchema"
    <xsd:include schemaLocation="BookCatalogue.xsd"/>
    <xsd:complexType name="LocalType">
              <xsd:element name="LocalElement" type="xsd:string"
                minOccurs="0" maxOccurs="unbounded"/>
    <xsd:element name="Library">
                  <xsd:element name="BookCatalogue">
                             <xsd:element ref="lib:Book"
                                minOccurs="0" maxOccurs="unbounded"/>
                             <xsd:element name="somelocalelement"

> Notice niether Book or LocalType are prefixed because there is no 
> default namespace.  

No, with Approach 3 you need to explicitly qualify all references -
lib:Book, lib:LocalType - since there is no default namespace.

Thanks for the comments!  /Roger