File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes dateTime pattern problem in schema Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "dateTime pattern problem in schema" Watch "dateTime pattern problem in schema" New topic

dateTime pattern problem in schema

Sverre Moe
Ranch Hand

Joined: Jul 10, 2007
Posts: 110
I have a problem with a dateTime element of my schema. It will not accept my dateTime pattern

cvc-pattern-valid: Value '18.11.2011 01:00:00.000' is not facet-valid with respect to pattern 'DD.MM.YYYY hh:mm:ss.SSS' for type 'DateTime'

If I remove the simpleType and just use dateTime as type on the element the following dateTime pattern is required and works: YYYY-MM-DDThh:mm:ss
I want to use the pattern DD.MM.YYYY hh:mm:ss.SSS. How can I configure that in my schema?
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 633
Before making a workable custom dataType, it is worth noting that xml is envelopping term including a wide range of interrelated technologies. If xs:dateTime is designed in a certain way to faciliate globalization/localization, it would be wise sometimes to work with it rather than against.

To achieve such special format which understandably inspired generally by a range of programming languages, it is advisable to transform it to the format conform to xs:dateTime in that programming language during the authoring time and consumming time. If the application (of certain language) is schema-aware, using xs:dateTime directly have further advantage of more effectivel data typing...

Having said, you can do a restriction based on xs:string (or some of its derived type such as normalizedString or tokens...)

This pattern is sort of coarse-grained: it can happily validate hours, minutes and seconds, days in range (01-31), months in range (01-12) and year in four digits.

But for date, it certainly is not quite enough, 28/30/31 day-month can more easily be accommodated by slight expansion of it. I leave it to you. But for leap year 29 day February, it is more cumbersome needing enumeration... It can be done for quite a few centuries without outrangeous inflated the pattern, but still it is unavoidably awkward in the look, though certainly not too difficult in practice.
I agree. Here's the link:
subject: dateTime pattern problem in schema
jQuery in Action, 3rd edition