XML : XSD from XML with data validations

I have a simple xml,

  <?xml version="1.0" encoding="UTF-8"?>  <Metadata>      <Data Name="Title" Value="This is a new title." />      <Data Name="Licensing_Window_Start" Value="2016-09-01" />      <Data Name="Licensing_Window_End" Value="2016-09-14" />      <Data Name="Preview_Period" Value="60" />  </Metadata>    

I'm able to generate xsd online for the above xml like this,

  <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">  <xs:element name="Metadata">  <xs:complexType>    <xs:sequence>      <xs:element name="Data" maxOccurs="unbounded" minOccurs="0">        <xs:complexType>          <xs:simpleContent>            <xs:extension base="xs:string">              <xs:attribute type="xs:string" name="Name" use="required"/>              <xs:attribute type="xs:string" name="Value" use="required"/>            </xs:extension>          </xs:simpleContent>        </xs:complexType>      </xs:element>    </xs:sequence>  </xs:complexType>  </xs:element>  </xs:schema>    

But what I'm trying to validate is, for <Data> tag, for the attribute Name the value Title is mandatory and need to define minlength and maxlength for the value of Value.

Is it possible to create the xsd with the type of validations I mentioned above?

No comments:

Post a Comment