my dog learned polymorphism*
The moose likes XML and Related Technologies and the fly likes XMl schema 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 "XMl schema " Watch "XMl schema " New topic
Author

XMl schema

Abhi Venu
Ranch Hand

Joined: Jul 09, 2009
Posts: 73

I am creating a XML schema file I am struck at one point If any of you can help me please do it.

I have a element like this


<xs:element name="Country_name" minOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="50" />
</xs:restriction>
</xs:simpleType>
</xs:element>


Thing i wanted is that if this country_name element holds a value "GREECE" in the XML file another element i.e the one shown below
should be mandatory else it should not be mandatory

<xs:element name="University" minOccurs="1">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:maxLength value="50" />
</xs:restriction>
</xs:simpleType>
</xs:element>


Can it be done in scheam i.e ina .xsd file?

Aslo another need is that based on value on One element i need to choose one of the two elements

like if element type==kid

i should have a element ice cream

else if type = men

i should have a element noodles can this selection of element based on the data on tag be done in xsd file

please help


A table, a chair, a bowl of fruit and a violin; what else does a man need to be happy?:Einstein
Abhi Venu
Ranch Hand

Joined: Jul 09, 2009
Posts: 73
Is there no 'body' to help 'any' body
Jaikiran Pai
Marshal

Joined: Jul 20, 2005
Posts: 9947
    
161

I don't think that kind of "restriction" is possible within the xsd. You will have to add that kind of validation outside of the xsd, in your code.

[My Blog] [JavaRanch Journal]
Abhi Venu
Ranch Hand

Joined: Jul 09, 2009
Posts: 73
ThankYou
 
wood burning stoves
 
subject: XMl schema
 
Similar Threads
XSD element validation
Invalid type (xsi:type) is set when XML request is generated from web service client
in Schema Dynamic value for maxLength - help
unble to validate xml against schema