• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

getting royally SCREWED by xjc (twice!)

 
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi...

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:

<xsd:element name="ValidityTime" type="xs:dateTime" minOccurs="0">

, 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 xs:DateTime 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"
parseMethod="com.fnx.security.services.auth.Authorizer.parseDate"
printMethod="com.fnx.security.services.auth.Authorizer.printDate"
/>

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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic