• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

[XSD] complexType conditional

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
XML FILE:
<wap-provisioningdoc version="1.0">
<characteristic type="BOOTSTRAP">
<parm name="PROVURL" value="http://55555"/>
</characteristic>
<characteristic type="PXLOGICAL">
<parm name="PROXY-ID" value="PROXY1"/>
<parm name="NAME" value="Proxy 1"/>
<parm name="STARTPAGE" value="Homepage_URL"/>
<characteristic type="PORT">
<parm name="PORTNBR" value="8080"/>
</characteristic>
<characteristic type="PXPHYSICAL">
<parm name="PXADDR" value="131.111.3.4"/>
<parm name="PXADDRTYPE" value="IPV4"/>
<parm name="TO-NAPID" value="Browsing_GPRS"/>
</characteristic>
</characteristic>
.....


I'd like to use a XML schema file to perform validation tests. The XML to test is very particular. I will try to give you a clear explanation.

For instance an element characteristic that has an attribute type "PXLOGICAL" can occur 0 or more times. If it exists, the element parm with name "NAME" MUST exist, the others are optional.

How can do this? How can I create different "complexType" and used them depending of the characteristic type?

<xs:complexType name="characteristicType">
<xs:attribute name="name" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="BOOTSTRAP"/> (occur 0 or more)
<xs:enumeration value="PXLOGICAL"/> (occur 0 or more) But if exits, should follow parmTypePXLOGICAL rules
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>


<xs:complexType name="parmTypePXLOGICAL">
<xs:attribute name="name" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="PROXY-ID"/> (the paramater is required)
<xs:enumeration value="NAME"/> (the paramater is required)
<xs:enumeration value="STARTPAGE"/> (occur 0 or 1 time)
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
 
This is my favorite tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic