Um - must learn to type faster! (And think faster too!)
(Already discussed by Michael in
http://lists.xml.org/archives/xml-dev/200809/msg00159.html)
Original Message From: "Pete Cordell" <>
>
> Original Message From: "Michael Kay"
>
>>> I think XSD 1.1 allows some of the solution. But it seems
>>> that assertions are not allowed on elements
>>
>> Assertions are defined on types, rather than elements, but that just
>> means
>> you need to assign the element a distinguishing type.
>
> So, since you can't have two consecutive elements with the same name, but
> different types (Have I got that right?), you'd put the assertion on the
> parent type definition - right?
>
> And rather than the parents assertion trying to describe a complete
> content
> model of its children, you could use alternatives within the same
> complexType for defining the sub-types, and then hopefully define a
> simpler
> assertion in the parent to ensure that the appropriate sub-type has been
> chosen. For example, in abbreviated XSD notation:
>
> <xs:element name='entry' type='entryType'>
>
> <xs:complexType name='entryType'>
> <xs:assert test="category[1]/@scheme = 'http://www.dig.com/privacy'"/>
> <xs:assert
> test="category[2]/@scheme = 'http://www.dig.com/fishingType'"/>
> <xs:sequence>
> <xs:element name='category' type='categoryType'>
> <xs:element name='category' type='categoryType'>
> ...
>
> <xs:complexType name='categoryType'>
> <xs:alternative test=""@scheme = 'http://www.dig.com/privacy'"
> type="categoryPrivacyType">
> <xs:alternative test=""@scheme = 'http://www.dig.com/fishingType'"
> type="categoryFishingType">
> ...
>
> Seem reasonable?
>
> Pete Cordell
> Codalogic Ltd
> Interface XML to C++ the easy way using XML C++
> data binding to convert XSD schemas to C++ classes.
> Visit http://www.codalogic.com/lmx/ for more info
>
Pete Cordell
Codalogic Ltd
Interface XML to C++ the easy way using XML C++
data binding to convert XSD schemas to C++ classes.
Visit http://www.codalogic.com/lmx/ for more info