• 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

Problems with JAXB-generated javadoc code

 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a question about the JAXB-generated javadoc code.

So within the schema of interest, there are two "container" elements. One element represents "the report" and it has a couple attributes (timestamp, if it's production data or not). The other element represents one row of data and it has an id attribute. All the other elements represent the columns of data, and for the most part are simple types.

Here is an edited version (took out most columns and anonymized) of the schema:



My problem is with the generated Javadoc comments. Here is the top part of the javadoc for the complex type 'ReportRecord':



So on line 14 it correctly identifies the class name, and at line 19 the schema snippet has a name attribute.

But a similar example from the CompanyBillingReport class:




So, at lines 3 and 8, the information is missing. It's like JAXB didn't know what it was (a CompanyBillingReport class), when it was generating the javadoc. All it says is "anonymous class", and there's no name attribute on the schema snippet.

Is this a JAXB bug, or a problem with the schema?


 
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mike,

to be precisely JAXB doesn't say "anonymous class" but "anonymous complex type"

The difference between "ReportRecord" and "CompanyBillingReport" is that CompanyBillingReport is directly defined as a <element> with an anonymous complex type inside it. Therefore the embedded complex type is anonymous and JAXB transforms it in a different way by default. See the difference?

Marco
 
Mike Curwen
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Alright, there is that difference (which I did notice), but thought that was what one did when defining the 'top' node. So I've made a change to the schema (not that it's mine to change...)


I get what I want in the javadoc, but now the ObjectFactory has a new private field and public method that I don't know what they are for.

With the old schema, I get a fairly simple object factory:


But with the javadoc-corrected schema, I now get:


Is this a non-important change? It certainly doesn't (seem to) break any of my code that uses the JAXB objects.
 
Marco Ehrentreich
best scout
Posts: 1294
Scala IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Mike,

I'm not sure why JAXB creates this third factory method for your modified schema. Unfortunately it's some time ago when i used JAXB the last time

Basically the "normal" classes wrapped in a JAXBElement just contain additional XML specific information (have a look at the API). But you can use the other classes without this and simply construct your object hierarchies just like with any other POJOs. I just used this JAXBElement wrapper for the root element of an XML document, i.e. I wrapped the root element with a JAXBElement before giving it to the Marshaller and it's a JAXBElement you get from the Unmarshaller when parsing a XML document. Then you have to call jaxbElement.getValue() to get the "real" root object of a tree hierarchy.

Perphaps someone other knows more exactly what this is good for...

Marco
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic