aspose file tools*
The moose likes XML and Related Technologies and the fly likes Problems with JAXB-generated javadoc code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Problems with JAXB-generated javadoc code" Watch "Problems with JAXB-generated javadoc code" New topic
Author

Problems with JAXB-generated javadoc code

Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

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?


Marco Ehrentreich
best scout
Bartender

Joined: Mar 07, 2007
Posts: 1278

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

Joined: Feb 20, 2001
Posts: 3695

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
Bartender

Joined: Mar 07, 2007
Posts: 1278

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problems with JAXB-generated javadoc code
 
Similar Threads
XML schema validation
XML valiadation using schema
schema generation
problem in applying restriction on xml attribute jaxb i.e. unable to do validation for attributes
Unique particle attribution rule bit me - why?