[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]
Re: [xml-dev] Use xsd to specify multiple instances of existing element
- From: "Pete Cordell" <petexmldev@codalogic.com>
- To: "Michael Kay" <mike@saxonica.com>,"'Andrew Welch'" <andrew.j.welch@gmail.com>
- Date: Mon, 22 Sep 2008 17:39:31 +0100
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
[Date Prev]
| [Thread Prev]
| [Thread Next]
| [Date Next]
--
[Date Index]
| [Thread Index]