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

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 UTC