OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] Use xsd to specify multiple instances of existing element

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'"/>
            test="category[2]/@scheme = 'http://www.dig.com/fishingType'"/>
        <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'"
    <xs:alternative test=""@scheme = 'http://www.dig.com/fishingType'"

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]

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 1993-2007 XML.org. This site is hosted by OASIS