We have a bunch of XSD's where they are bound by JAXB and we are using a global binding as
This means, default bindings are applied to all xsds.
However, I need to apply a particular customization to a particular element of one of those xsd, which is of type xs:dateTime. This customization is applicable only to that particular element in that particular xsd. But all the current global bindings are still to be applied. The new customization is an additional one.
I could not find any examples in doing element specific customization in an external customization file. Could some one, provide me a pointer of such examples.
You can change it to customize a specific schema component. Something which looks like this as an external xjb customization file (with the xpath node attribute pointing to the specific targetted node).
amendment note I had tried to be figurative and informative in the node attribute expression, but hastily put name() instead of @name in the predicates.
It sure is thereby lack of realism.
As it is not an issue in the followup posts, I change it back directly in the code section.
I'm trying to set the timezone of the data that is being parsed to GMT and I'm doing like below.
The reason behind this customization is we are getting this date from one of the application and they send us the data is UTC, but no explicit indication of the timezone and when we forward that to anothre application, they are treating it as local... so we did some hacking such that we put "z" in the last. But now we wanted to change this by doing the customization.
So to accomplish this, I see two approaches, but both of them are stuck with other issues.
1) as mentioned above, creating XMLGregorian object and setting TimeZone.. but I don't know what would be the offset, such that it gets me "Z" when converted to GregorianCalendar.
2) Creating XMLGregorianCalendar from GregorianCalendar, whose Timezone is set to "GMT".. but I do not want to use SimpleDateFormat to build date object from String, due to Thread safety issues and FastDateFormat does not have an option to parse string to date...
Hmm, I was able to straighten this out, by checking if TimeZone is not set on XMLGregorianCalendar object, by checking for "DatatypeConstants.FIELD_UNDEFINED" and setting the timezone to "0".
Everything works great, if I'm dealing with just one schema and with only customization..
But applying this concept to my real problem at hand, I'm facing trouble
when the required objects are generated, it is also creating org.w3._2001.xmlschema.Adapter1.java
I have two issues with this class and looking for some customization.
1) I should be able to specify a package for this class, instead of org.w3.2001.xmlschema.
Apparently CustomDateTimeBinder is neither XMLGregorianCalendar nor String. So I need to change these methods, such that appropriate methods of CustomDateTimeBinder class are called when Marshalling and Unmarshalling is being done.
All this is fine, if I'm working on some coding and testing locally, but as usual build process is automated and which means, changing the methods of unmarshall and marshall is not that easy. So, how do we handle this situation.