Forum

How to make generated classes contain Javadoc from XML Schema documentation

2 Replies Posted since 26/05/2010

  • stonemetal's profile image

    Member
    stonemetal

    3 Posts

    How to make generated classes contain Javadoc from XML Schema documentation

    I'm currently working with an XML Schema that has / on most types and elements. When I generate Java Beans from this XML Schema, then the Javadoc of those Beans only contains some generic generated information about the allowed content of the type/element.

    I'd like to see the content of the tag in the relevant places (for example the content of that tag for a complextType should show up in the Javadoc of the class generated to represent that complexType).

    Is there any way to achieve this?

    Edit: this XML Schema will be used in a WSDL with JAX-WS, so this tag might be appropriate as well.

    Edit 2: I've read about . From what I understand I can specify that either in a separate JAXB binding file or directly in the XML Schema. That would almost solve my problem. But I'd rather use the existing tag, since Javadoc is not the primary target of the documentation (it's information about the data structure primarily and not about the Java Beans generated from it) and to allow non-JAXB tools to access the information as well. Providing the documentation in both and xsd:documentation> "feels" wrong, because I'm duplicating data (and work) for no good reason.

    Edit 3: Thanks to the answer by Pascal I realized that I already have half a solution: The of complexTypes is written to the beginning of its Javadoc! The problem is still that only that complexTypes is used and simpleTypes (which can also result in a class) and elements are still Javadoc-less.

  • Joachim Sauer's profile image

    Member
    Joachim Sauer

    2 Posts

    Replied at 14:16 - 26/05/2010

    Re: How to make generated classes contain Javadoc from XML Schema documentation

    The first thing I would do with this code is create the types Admin and Student, both of which inherit from the base type User. These classes should have a doStuff() method where you hide the rest of this logic.

    As a rule of thumb, any time you catch yourself switching on type, you can use polymorphism instead.

  • Keith Randall's profile image

    Member
    Keith Randall

    2 Posts

    Replied at 14:16 - 26/05/2010

    Re: How to make generated classes contain Javadoc from XML Schema documentation

    Based just on the variable names, I'm guessing that you should subclass User (or whatever it is that has a userType variable) into AdminUser and StudentUser (and possibly others) and use polymorphism.

  •  

    You must be logged in to post replies

  • Page 1 of 1

Back to top

Sunderland Software City, Evolve Business Centre,
Cygnet Way, Rainton Bridge South Business Park,
Houghton Le Spring, DH4 5QY

Site by SUMO