Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Schema Help

From: "Mike Sharp" <rdcpro@-------.--->
To: 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
>>
>> 




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent