Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » XSD » Conditional in schema(Required element if another is present)
Conditional in schema [message #1063071] Wed, 12 June 2013 06:40
Pete Danes is currently offline Pete DanesFriend
Messages: 1
Registered: June 2013
Junior Member
Sorry if this is simple or already answered somewhere - I couldn't find it with any of the search terms I tried.

I have some date input, that I would like to make in a conditional cascade, like this:

1. Entire date is in ISO format order - YYYY-MM-DD
2. Month and day may contain 'illegal' values, in particular, zero or Feb. 30
3. Key (and the reason for this post), if month is present, year must be present; if day is present, month and year must be present. So effectively, the date may be 'YYYY' or 'YYYY-MM' or 'YYYY-MM-DD'. What I have so far is just a simple specification that checks the individual elements, but not a joined plan as I have described. Is this possible with XSD?

<xs:element name='DatumOd' minOccurs='0' maxOccurs='1'>
<xs:simpleType>
<xs:restriction base='xs:string'>
<xs:minLength value='4'/>
<xs:maxLength value='10'/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name='RokStary' minOccurs='0' maxOccurs='1'>
<xs:simpleType>
<xs:restriction base='xs:short'>
<xs:minInclusive value='700' />
<xs:maxInclusive value='2013' />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name='MesicStary' minOccurs='0' maxOccurs='1'>
<xs:simpleType>
<xs:restriction base='xs:byte'>
<xs:minInclusive value='0' />
<xs:maxInclusive value='12' />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name='DenStary' minOccurs='0' maxOccurs='1'>
<xs:simpleType>
<xs:restriction base='xs:byte'>
<xs:minInclusive value='0' />
<xs:maxInclusive value='31' />
</xs:restriction>
</xs:simpleType>
</xs:element>
Previous Topic:Problems with complexType?
Next Topic:Validate XML file using XSD Schema and parsing in DOM parser
Goto Forum:
  


Current Time: Fri Apr 19 04:33:49 GMT 2024

Powered by FUDForum. Page generated in 0.01916 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top