Skip to main content

XSD Date versus XMLGregorianCalendar

1 reply [Last post]
Joined: 2007-04-13

If an XSD contains the following:

A specific date, in the format YYYY-MM-DD, at which the applicable
information is automatically declassified.

And XJC generates JAXB getter/setter using XMLGregorian Calendar for "declassDate", then the actual data written to the XML file upon marshalling will include date and time.

XSD/XML validators consider this a violation. The validators insist that only a date [and not also time] should be written.

Is there a way to enlighten XJC to generate JAXB code that only writes date [and not time]? Thanks.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2007-04-13

Inserted the following into my binding.xjb:

printMethod="javax.xml.bind.DatatypeConverter.printDate" />

That succeeded in coercing XJC to generate Date and not XMLGregorianCalendar but only for file IC-ISM-v2.xsd. I have several XSD files, all part of a schema tree, that need the same treatment, some using namespace "xs" not "xsd". If I duplicate the above for each XSD file, the compiler complains that only one "globalBindings" can exist. But if I string the XSD files, separated by spaces, in the schemaLocation reference, I get other errors.

Can anyone suggest the syntax to handle multiple XSD files and multiple namespaces? Thanks.