File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Web Services Certification (SCDJWS/OCEJWSD) and the fly likes XMLGregorianCalender maps to xs:anySimpleType 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 » Certification » Web Services Certification (SCDJWS/OCEJWSD)
Bookmark "XMLGregorianCalender maps to xs:anySimpleType" Watch "XMLGregorianCalender maps to xs:anySimpleType" New topic

XMLGregorianCalender maps to xs:anySimpleType

Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 1124
In MZ's version 5 notes, p 137, it says javax.xml.datatype.XMLGregorianCalender maps to xs:anySimpleType in a schema.
It says "It is (XMLGregorianCalender)statically mapped to xs:anySimpleType, the common schema type from which all XML schema calendar types are derived."

But why XMLGregorianCalender won't map to xs:datetime?
For me, it makes more sense to map the Calender object to datatime instead of anySimpleType.

Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper

Joined: Apr 07, 2010
Posts: 2106

Did you check the JAXB specifications for the reason?
Himai Minh
Ranch Hand

Joined: Jul 29, 2012
Posts: 1124
I found this site:
We have to annotation XMLGregorianCalender with @XmlSchemaType in order to map XMLGregorianCalender to xs:dateTime.

If we don't annotate it wit @XmlSchemaType, the schema type of the XMLGregorianCalender is not known until runtime. So, it can only be mapped to xs:anySimpleType.
This is from :

So personally, I think it is more appropriate to annotate XMLGregorianCalender with @XmlSchemaType (name="dateTime").
I think it is not recommended not to annotate the Calendar object in Java, as it will be mapped by xs:anySimpleType.
I agree. Here's the link:
subject: XMLGregorianCalender maps to xs:anySimpleType
It's not a secret anymore!