Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: Schema Help [Thread Next] Re: Schema HelpTo: NULL Date: 1/3/2005 11:40:00 PM That's called a co-occurrance constraint, and W3C XML Schema doesn't support that. You might be able to create a hack using substitution groups or something, but it would be ugly. RelaxNG and Schematron both support co-occurance constraints, but these aren't W3C XML Schema--they're a separate syntax. Schematron uses an XSLT to process this, so you could create your own validation rules for this. As Han suggests, using xs:choice is the only way in schema to do this. Regards, Mike Sharp "David W. Rogers" <DavidWRogers@d...> wrote in message news:9F5240CE-C4A1-4A6B-B5DF-5146D63FF6E2@m...... > Yes, I have considered xs:choice, however, I don't see how I would apply > that. In this case, I always want all of the elements in the order listed, > but, I only want to allow content (specific content) in one of those > elements. > > Thanks, > David > > "Han" wrote: > >> Have you considered xs:choice instead of xs:sequence? >> -- >> Pohwan Han. Seoul. Have a nice day. >> "David W. Rogers" <DavidWRogers@d...> wrote in >> message >> news:423DF2B1-74BC-4F26-AFE2-99592532806A@m...... >> >I am creating an evaluation form, to capture a question of the format: >> > >> > 1) I was able to hear everything the speaker said: >> > >> > Strongly Disagree Neutral Strongly Agree >> > [ ] [ ] [ ] >> > [ ] [ ] >> > >> > I am creating a schema to validate an XML document that has: >> > >> > <RankedQuery ID="1" Text="I was able to hear everything the speaker >> > said:"> >> > <StronglyDisagree></StronglyDisagree> >> > <SortofDisagree></SortofDisagree> >> > <Neutral>x</Neutral> >> > <SortofAgree></SortofAgree> >> > <StronglyAgree></StronglyAgree> >> > </RankedQuery> >> > >> > >> > I only want one of these to be able to have an 'x' in it at a time >> > (like a >> > radio button choice). My schema does not enforce that: >> > >> > <xs:element name="RankedQuery"> >> > <xs:complexType> >> > <xs:sequence> >> > <xs:element ref="StronglyDisagree"/> >> > <xs:element ref="SortofDisagree"/> >> > <xs:element ref="Neutral"/> >> > <xs:element ref="SortofAgree"/> >> > <xs:element ref="StronglyAgree"/> >> > </xs:sequence> >> > <xs:attribute name="ID" use="required" type="xs:integer"/> >> > <xs:attribute name="Text" use="required"/> >> > </xs:complexType> >> > </xs:element> >> > >> > <xs:element name="Neutral" type="xType"/> >> > <xs:element name="SortofAgree" type="xType"/> >> > <xs:element name="SortofDisagree" type="xType"/> >> > <xs:element name="StronglyAgree" type="xType"/> >> > <xs:element name="StronglyDisagree" type="xType"/> >> > <xs:simpleType name="xType"> >> > <xs:restriction base="xs:string"> >> > <xs:enumeration value=""/> >> > <xs:enumeration value="x"/> >> > <xs:enumeration value="X"/> >> > </xs:restriction> >> > </xs:simpleType> >> > >> > >> > Can someone redirect me in a direction that will enforce that one and >> > only >> > one of the xtype elements can have an 'x' in it? >> > >> > Thanks, >> > David >> >> | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
