Chris,

 

If you check the XMLSchema spec: 

http://www.w3.org/TR/xmlschema-2/#dateTime 3.2.7.1 explains the lexical 
representation of datetime. This '-'? yyyy '-' mm '-' dd 'T' hh ':' mm ':' ss 
('.' s+)? (zzzzzz)? is the production that you can restrict in a derived 
restriction. If you don't restrict using that production no instance will match 
it, so you'll have a type with no valid values.

 

As for XMLBeans serializing according to a pattern, it will as long as the 
instance is a valid instance of the defined type.

 

Also check the definition of pattern: 
http://www.w3.org/TR/xmlschema-2/#dt-pattern

 

I hope this helps,

Cezar

  _____  

From: Chris Hopkins [mailto:chrishopk...@gmail.com] 
Sent: Tuesday, December 14, 2010 12:10 PM
To: user@xmlbeans.apache.org
Subject: XMLBeans enforcement of xs:pattern in simple type?

 

Hi all -

 

I'm working with a schema that has the following simple type:

 

                <xs:simpleType name="DateTimeGroupType">

                                <xs:annotation>

                                                <xs:documentation>A date time 
group always in Zulu time.</xs:documentation>

                                </xs:annotation>

                                <xs:restriction base="xs:dateTime">

                  <xs:pattern 
value="^(3[0-1]|2[0-9]|1[0-9]|0[1-9])(0[0-9]|1[0-9]|2[0-3])([0-5][0-9])\sZ\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s[0-9]{2}$"/>

                </xs:restriction>

                </xs:simpleType>

 

I thought, perhaps naively, that specifying a pattern would force the XMLBeans 
generated classes to validate against that pattern including producing a String 
representation conforming to that pattern when I call getStringValue(). This is 
not the result that I'm getting but perhaps I'm doing something wrong with the 
definition.

 

Does anyone have any insight or experience doing the same thing?

 

Thanks,

Chris

Reply via email to