dcsimg
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: XML
Expertise: Advanced
Aug 25, 2004

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Regular Expression Validation in XSD

The following code performs powerful Date type validation in XSD. It validates date fields with timestamp (optional) in yyyyMMdd hh:MM:ss.ffffff format.

If your XML file contains the element ValueDate, the corresponding XSD will be this:


<xs:element name="ValueDate" type="dateType"/>

<xs:simpleType name= "timestampType">
  <xs:restriction base = "xs:string">
   <xs:pattern value='[1-9][0-9][0-9][0-9](([0][1|3|5|7|8])([0][1-9]|[1-2][0-9]|[3][0-1])|([0][4|6|9])
([0][1-9]|[1-2][0-9]|[3][0])|([0][2])([0][1-9]|[1-2][0-9])|([1][0|2])([0][1-9]|[1-2][0-9]|[3][0-1])|([1]
[1])([0][1-9]|[1-2][0-9]|[3][0]))([ ]([2][1-4]|[0][0-9]|[1][0-9])[:]([0-5][0-9]|[6][0])[:]([0-5][0-9]|[6]
[0])[.][0-9]{6})*'/>
  </xs:restriction>
</xs:simpleType>
</code></pre>
Supal Chowdhury
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Thanks for your registration, follow us on our social networks to keep up-to-date