You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@xmlbeans.apache.org by Radhakrishnan J <ra...@tavant.com> on 2004/08/10 16:55:53 UTC

Problem with pattern facet for date / datetime types

Hi,

I had made a post earlier on this topic and didn't attract much attention.
So herez another effort -

We are having problems with derivation by restriction of built-in date /
dateTime types using the 'pattern' facet. 

Following is how the schema looks like -

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="unqualified"
	targetNamespace="http://www.tavant.com/xmldatatype"
xmlns:ns="http://www.tavant.com/xmldatatype">
	<xs:element name="DateTimes" type="ns:DateTimes"/>
	<xs:complexType name="DateTimes">
		<xs:sequence>
			<xs:element name="extendedDate1"
type="ns:extendedDate1" />
			<xs:element name="extendedDate2"
type="ns:extendedDate2" />
			<xs:element name="extendedDateTime1"
type="ns:extendedDateTime1"/>
			<xs:element name="extendedDateTime2"
type="ns:extendedDateTime2"/>
			<xs:element name="extendedDateTimeAny3"
type="ns:extendedDateTimeAny3"/>
		</xs:sequence>
	</xs:complexType>

	<xs:simpleType name="extendedDate1">
		<xs:restriction base="xs:date">
			<xs:pattern value="\d\d\d\d-\d\d-\d\d" />
		</xs:restriction>
	</xs:simpleType>


	<xs:simpleType name="extendedDate2">
		<xs:restriction base="xs:normalizedString">
			<xs:pattern value="\d\d\d\d-\d\d-\d\d" />
		</xs:restriction>
	</xs:simpleType>

	<xs:simpleType name="extendedDateTime1">
		<xs:restriction base="xs:dateTime">
			<xs:pattern
value="\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d\.\d\d\d(Z|(\+|-)\d\d:\d\d)" />
		</xs:restriction>
	</xs:simpleType>


	<xs:simpleType name="extendedDateTime2">
		<xs:restriction base="xs:dateTime">
			<xs:pattern
value="\d\d\d\d-\d\d-\d\dT\d\d:\d\d:\d\d\(Z|(\+|-)\d\d:\d\d)" />
		</xs:restriction>
	</xs:simpleType>

	<xs:simpleType name="extendedDateTimeAny3">
		<xs:union memberTypes="ns:extendedDate1
ns:extendedDateTime2" ></xs:union>
	</xs:simpleType>
</xs:schema>

There are various ways by which the 'extendedDate1' element can be
populated. One of the signatures is through a java.util.Calendar object. The
problem is that XmlBean does not use the pattern facet to extract the
substring from the 'java.util.Calendar.toString()'. IMHO, this is a bug. 

(1) Either a mutator with a String in the signature must be provided.
(2) OR if a calendar is provided, then XmlBean should internally extract the
substring from the Calendar's string representation that conforms to the
pattern.

Am I missing some feature that lets me tell XmlBean how should it format the
string representation of Calendar objects ? If not, I think this should
qualify as a bug.

Thanks,
Radhakrishnan 
Extn  367

http://kwiki-infra.india.tavant.com/kwiki/



- ---------------------------------------------------------------------
To unsubscribe, e-mail:   xmlbeans-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-user-help@xml.apache.org
Apache XMLBeans Project -- URL: http://xml.apache.org/xmlbeans/