![]() |
![]() | ![]() | ![]() | Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: newbie xml xsd modelling problem >Thread Next - Re: newbie xml xsd modelling problem Re: newbie xml xsd modelling problemTo: NULL Date: 4/3/2005 8:47:00 PM Hi Martin, Thank you for your comments. See my remarks below. ----- Original Message ----- From: "Martin Honnen" <mahotrash@y...> Newsgroups: microsoft.public.xml Sent: Sunday, April 03, 2005 6:45 PM Subject: Re: newbie xml xsd modelling problem > > > Tis Veugen wrote: > > >> I have a modelling problem that I would like to make clear with these >> xml-file and xsd-file. >> >> The xsd-file: >> >> <xsd:simpleType name="st1"> >> <xsd:restriction base="xsd:NMTOKEN"> >> <xsd:enumeration value="v1"/> >> <xsd:enumeration value="v2"/> >> <xsd:enumeration value="v3"/> >> </xsd:restriction> >> </xsd:simpleType> >> >> <xsd:complexType name="ct1"> >> <xsd:choice> >> <xsd:sequence> >> <xsd:attribute name="type" type="st1" fixed="v1"/> >> <xsd:element name="str" type="string"/> > > Have you actually tried to use that schema with a validating XML parser or > a schema parser? It would tell you that the xsd:attribute is not allowed > inside of the xsd:sequence. The XRay XML Editor does not complain about it. According to my book , XML Developer's Guide, it's allowed. Otherwise, how could such a choice of 3 possibilities regarding attributes be modelled? >> </xsd:sequence> >> <xsd:sequence> >> <xsd:element name="str" type="string"/> >> </xsd:sequence> >> <xsd:sequence> >> <xsd:attribute name="type" type="st1"/> > > Same here. > > >> The xml-file: >> >> <my_ct type="v1"> >> <str> my other data </str> >> </my_ct> >> >> <my_ct> >> <str> my data </str> >> </my_ct> >> >> <my_ct type="v2"> >> </my_ct> >> >> <my_ct type="v3"> >> </my_ct> >> >> PROBLEM: >> How to prevent that the following lines would be allowed, according to >> the 3rd choice : >> <my_ct type="v1"> >> </my_ct> >> So, how should the xsd file look like? > > An W3C XML schema doesn't allow you to constraint the element content > structure based on an attribute value. > With a Schematron schema you can model such constraints as you simply > express them using XPath expressions: > <http://xml.ascc.net/resource/schematron/schematron.html> Well, for a newbie it's already difficult enough browsing through all this new stuff. And so, I'm hesitating to learn yet another standard. Therefore, I was looking for an XSD solution. > -- > > Martin Honnen --- MVP XML > http://JavaScript.FAQTs.com/ | ![]() | ![]() | ![]() |
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | |||||
|
