This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
the task as i've been chosen to implement it, is to receive an xml schema from someone, jave jaxb generate files from it (using what ever customization i need) then using websphere, re-generate wsdl (which will contain generated xsd schema's (from the generated classes).
almost everything went ok, except when it came to an element defined using a simpleType called 'ourTime' which was derived from xs:dateTime.
if i were to directly use the xs:dateTime on the element in question instead of the simpleType ourTime like so:
, then the jaxb classes would be generated with XMLGregorianCalender which would have the annotation @XMLSchemaType(name='dateTime') thus allowing re-generation of the schema correctly with the definition xs:dateTime.
however, if i would use "ourTime' for the definition as specified , i'd XMLGregorianCalender WITHOUT the annotation @XMLSchemaType which cause the element to be defined as xs:anySimpleType in the re-generated schema.
since java.util.Date can be translated by default to xsateTime i tried another approach using jxb:javaType with java.util.Date as the name customization like so:
<jaxb:javaType name="java.util.Date" xmlType="ourTime"
where the print and parse method would use XMLGregorianCalender internally to output xsd complient date string.
however this does not work, as the annotated attribute in the class is generated with @XMLElement(type=String.class) which causes the generated element in the schema to be typed as xs:String.
changing the type manually to Date.class works fine, but the main point here is not change the original schema, generated classes and generated schema.