W3C home > Mailing lists > Public > xmlschema-dev@w3.org > May 2007

Re: XML Schemas patterns (was: Re: Defining recursive elements?)

From: <noah_mendelsohn@us.ibm.com>
Date: Thu, 17 May 2007 18:53:45 -0400
To: "Pete Cordell" <petexmldev@tech-know-ware.com>
Cc: xmlschema-dev@w3.org
Message-ID: <OF8DACED08.0C08C870-ON852572DE.007D2BE3-852572DE.007DA29A@lotus.com>

Pete Cordell writes:

> I often see things like:
> 
>   <element name="thing">
>     <sequence>
>         <element name="height" type="measurementType"/>
>         <element name="width" type="measurementType"/>
>     </sequence>
>   </element>
> 
> <complexType name="measurementType">
>     <simpleContent>
>         <extension base="float">
>             <attribute name="units" type="string"/>
>         </extension>...
> 
> To me, this results in a lot of duplication if everything is to be made 
> global.

Let's see:

  <element name="thing">
    <sequence>
        <element ref="height"/>
        <element ref="width"/>
    </sequence>
  </element>

  <element name="height" type="measurementType"/>
  <element name="width" type="measurementType"/>
  <complexType name="measurementType">
    <simpleContent>
        <extension base="float">
            <attribute name="units" type="string"/>
        </extension>...

I don't see a whole lot of duplication.  Like the type, the elements are 
declared in one place and used in another.  Of course, there would be more 
payoff on that if it turned out that widths or heights were also needed 
outside of "things".

> I think it would also be harder to read as you would see the 
> local ref to height and then have to find the global definition
> (which could be a long way away) to find out what it's type is.

Yes.  I acknowledged that the syntax of Schema 1.0 facilitates the use of 
locals vs. globals, and suggested that to be unfortunate.  I would have 
seriously considered having the syntax of your original be interpreted to 
define a global, I.e. to do some sort of folding so that what were 
syntactically duplicate (for some definition of duplicate) element 
declarations would be folded into a single global, with differences 
allowed only if some other syntax or "local" switch were thrown.  As it 
stands, the local syntax is indeed more convenient, as I said in my note.

For the reasons Michael Kay's been giving, plus the one's I've been 
contributing, I think that the >semantics< of globals are usually 
preferable, and I don't think you've given any examples to indicate to the 
contrary.

--------------------------------------
Noah Mendelsohn 
IBM Corporation
One Rogers Street
Cambridge, MA 02142
1-617-693-4036
--------------------------------------
Received on Thursday, 17 May 2007 23:07:00 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:59 GMT