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: Fri, 18 May 2007 14:49:48 -0400
To: "Pete Cordell" <petexmldev@tech-know-ware.com>
Cc: xmlschema-dev@w3.org
Message-ID: <OF10B5CDD8.924BB1C9-ON852572DF.0066DC21-852572DF.00674D10@lotus.com>

Pete Cordell writes:

> Also, I think you have problems if you want things like:
> 
>   <element name="employee">
>     <sequence>
>         <element name="id" type="employeeID"/>
>         ...
>     </sequence>
>   </element>
> 
>   <element name="vehicle">
>     <sequence>
>         <element name="id" type="vehicleID"/>
>         ...
>     </sequence>
>   </element>

Yes.  If that's the reason locals are there, if you need such conflicting 
definitions you should use locals.  Whether this is a good use of XML 
seems to be the subject of some debate.  If you had instead:

Also, I think you have problems if you want things like:

  <element name="employee">
    <sequence>
        <element employeeName="id" type="employeeID"/>
        ...
    </sequence>
  </element>

  <element name="vehicle">
    <sequence>
        <element vehicleName="id" type="vehicleID"/>
        ...
    </sequence>
  </element>

you would have what some people think is a nice property, particularly on 
the Web.  I.e., each qualified name such as vehicleName has one semantic. 
As a consequence, I think it's likely that for many purposes it will be 
easier to write robust stylesheets and XPaths, since you can just search 
for vehicleName if that's what you want.  Of course, if you want to search 
for anything with a name, then your original is easier, but be careful: 
the content rules for <name> in a <vehicle> are different than for <name> 
in an <employee>, so value comparisons are likely inappropriate anyway.

Speaking for myself, I think the more explicit forms such as vehicleName 
seem to me to be better markup in most cases.  Of course, there's nothing 
wrong with:

Also, I think you have problems if you want things like:

  <element name="employee">
    <sequence>
        <element ref="name"/>
        ...
    </sequence>
  </element>

  <element name="vehicle">
    <sequence>
        <element ref="name"/>
        ...
    </sequence>
  </element>

  <element name="name" type="string"/>

If you really do want uniform naming of the vehicles and the employees 
together.

Noah

--------------------------------------
Noah Mendelsohn 
IBM Corporation
One Rogers Street
Cambridge, MA 02142
1-617-693-4036
--------------------------------------
Received on Friday, 18 May 2007 18:49:14 GMT

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