File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes [XSD] complexType conditional Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "[XSD] complexType conditional" Watch "[XSD] complexType conditional" New topic

[XSD] complexType conditional

Brian Grey
Ranch Hand

Joined: Nov 15, 2002
Posts: 43
<wap-provisioningdoc version="1.0">
<characteristic type="BOOTSTRAP">
<parm name="PROVURL" value="http://55555"/>
<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 type="PXPHYSICAL">
<parm name="PXADDR" value=""/>
<parm name="PXADDRTYPE" value="IPV4"/>
<parm name="TO-NAPID" value="Browsing_GPRS"/>

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: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:complexType name="parmTypePXLOGICAL">
<xs:attribute name="name" use="required">
<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)
I agree. Here's the link:
subject: [XSD] complexType conditional
Similar Threads
schema generation
dynamic attribute definition in xsd
XML valiadation using schema
problem in applying unique constraint on xml attribute through xsd unique
unble to validate xml against schema