[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Use xsd to specify multiple instances of existing element
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] |
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|