[Home] [By Thread] [By Date] [Recent Entries]

  • From: "Pete Cordell" <petexmldev@c...>
  • To: "Michael Kay" <mike@s...>,"'Andrew Welch'" <andrew.j.welch@g...>
  • Date: Mon, 22 Sep 2008 17:51:21 +0100

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" <petexmldev@c...>
>
> 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




[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member