If your schema check cannot show an error when the DATE element of the data type is NULL, you can use the template [if you do not need to enter the required format];
I added an example, the implementation of such code will work on your tool,
This is an XML example:
<root> <date1>12/31/1999</date1> </root>
This is the corresponding XSD:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:include schemaLocation="Date_Def.xsd"/> <xs:element name="root"> <xs:complexType> <xs:sequence> <xs:element name="date1" type="DATE_TYPE" minOccurs="0" maxOccurs="1" /> </xs:sequence> </xs:complexType> </xs:element> </xs:schema>
Note that I am including another schema file that includes a definition of type DATE_TYPE,
Here is the Date_Def.xsd file:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:simpleType name="DATE_TYPE"> <xs:restriction base="xs:string"> <xs:pattern value="([0][1-9]|[1][0-2])/([0][1-9]|[1-2][0-9]|[3][0-1])/[1-2][0-9][0-9][0-9]"/> </xs:restriction> </xs:simpleType> </xs:schema>
The date format specified here is MM / DD / YYYY, null or Date with any other format is not accepted. If you want to accept also a null tag, replace the template with this.
<xs:pattern value="|(([0][1-9]|[1][0-2])/([0][1-9]|[1-2][0-9]|[3][0-1])/[1-2][0-9][0-9][0-9])"/>
Checking what accepts is either a null tag or a date-value for the template MM / DD / YYYY.
If you need more help on template design, then feel free to do it in SO, hope this helps. :-)
[note :: Definition type can also be defined in a single file, which requires additional namespaces mentioned in XML, as well as XSD files that define the external file is harmless and reused]
InfantPro'Aravind '
source share