XMLBeans enforcement of xs:pattern in simple type?

2010-12-14 Thread Chris Hopkins
Hi all –



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



xs:simpleType name=DateTimeGroupType

xs:annotation

xs:documentationA 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


RE: XMLBeans enforcement of xs:pattern in simple type?

2010-12-14 Thread Cezar Andrei
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 '-'?  '-' mm '-' dd 'T' hh ':' mm ':' ss 
('.' s+)? (zz)? 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:documentationA 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


Re: XMLBeans enforcement of xs:pattern in simple type?

2010-12-14 Thread Chris Hopkins
Ah...right...I forgot about that aspect of restrictions. Thanks for the
clarification!

On Tue, Dec 14, 2010 at 3:53 PM, Cezar Andrei cezar.and...@oracle.comwrote:

  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 '-'?  '-' mm '-' dd 'T' hh ':' mm ':'
 ss ('.' s+)? (zz)? 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:documentationA 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