0

I have a schema file and I am validating against an xml. But it is saying date of birth (date) isn't valid date. I just deleted other tags from the schema otherwise it would make it too long to read. Can anyone spot what I am doing wrong? I don't have much experience using xml schema before.

I am using vb.net by the way.

My xml as follow.

  <?xml version="1.0" encoding="UTF-8" ?>
  <EEL>
  <CANDIDATE>
  <SURNAME>JONNY</SURNAME>
  <FORENAME>WALKER</FORENAME>
  <DOB>29/12/2005</DOB>
  <SEX>M</SEX>  
  <POSTCODE>DD12DL</POSTCODE> 
  </CANDIDATE>
  </EEL>

in the schema,

<?xml version="1.0" encoding="UTF-8"?>
 <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="EEL">
    <xs:complexType>
        <xs:sequence>
            <xs:element maxOccurs="unbounded" name="CANDIDATE">
                <xs:complexType>
                    <xs:sequence>
                                               <xs:element name="DOB" type="xs:date" minOccurs ="1" maxOccurs="1" />
                                            </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>
</xs:element>

Laurence
  • 7,633
  • 21
  • 78
  • 129

3 Answers3

0

The date needs to be specified in the following form "YYYY-MM-DD", by default

Ezhil V
  • 894
  • 5
  • 11
0

XMLSchema requires an (almost) ISO 8601-formatted data string, which you haven't provided: http://www.w3.org/TR/xmlschema-2/#date

Marc B
  • 356,200
  • 43
  • 426
  • 500
0

Have a look at this question and this question.

They state that to be compatible with XSD declarations, dates in Xml files have to be declared in the ISO8601 format (or something very similar to it).

Community
  • 1
  • 1
O. R. Mapper
  • 20,083
  • 9
  • 69
  • 114
  • More precisely, XSD-defined dates use a subset of the formats permitted by ISO 8601, for example they don't allow the abbreviated form 20130318. – Michael Kay Mar 18 '13 at 21:07