You must Sign In to post a response.
  • Category: ASP.NET

    How to declare optional date field in XSD

    Hi All,

    I was using XSD to validate my incoming XML elements. It was throwing Invalid date field error.

    Below XSD File

    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.rg/2001/XMLSchema"
    targetNamespace="http://xxxy/ervices/V" elementFormDefault="qualified"
    attributeFormDefault="unqualified" >

    <xs:complexType name="FailType">
    <xs:element name="ConDt" type="xs:date" minOccurs="0" maxOccurs="1" nillable="true"/>
    <xs:element name="PreEn" type="xs:string" minOccurs="1" maxOccurs="1"/>

    XML File

    <Pat xmlns="http://xxxy/ervices/V">

    Please help me to resolve this.
  • #763235
    Finally I found answer from google.

    Below code will allow us to declare optional date field in XSD file.

    <xs:element name="ConDt" maxOccurs="unbounded" minOccurs="0">
    <xs:restriction base="xs:string">
    <xs:minLength value="0" />
    <xs:maxLength value="0" />
    <xs:restriction base="xs:date" />

  • Sign In to post your comments