permaculture playing cards*
The moose likes Web Services Certification (SCDJWS/OCEJWSD) and the fly likes Doubt on the JAXB: XML Schema to Java mapping for anonymous complex type. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Services Certification (SCDJWS/OCEJWSD)
Bookmark "Doubt on the JAXB: XML Schema to Java mapping for anonymous complex type." Watch "Doubt on the JAXB: XML Schema to Java mapping for anonymous complex type." New topic
Author

Doubt on the JAXB: XML Schema to Java mapping for anonymous complex type.

Kamal Tripathi
Ranch Hand

Joined: Oct 02, 2008
Posts: 86
Please take a look at for full schema

My Doubts is related to this snippet. I have removed other elements in this complexType for clarity.



When I run WSIMPORT on this schema. OrderType.java is generated. Here is how it looks.



It is an anonymous complex type. How did it decide on a name for this complex type.



Tried to look it up in JAXB Spec document. The closest that I could find was 3.6 An Example. I couldn't find an online spec (you need to download PDF and checkout the section) so can't put a html link here. This example looks like ItemType in the spec doc.

Other than that didn't find much in the spec. The other relevant sections that I looked in JAXB spec 2.1

6.7.3 Binding of an anonymous complex type definition
5.6.2 Java Element Class



So wanted to understand if vendors can apply it differently from the spec doc? If so how is the portability guaranteed. Here the element name "OrderItems" has been borrowed as class name as well, other JAXB vendor may not do so. In that case how would it guarantee portability.

Are we supposed to know the JAXB in such detail?? I have read couple of spec documents before and I find JAXB spec doc very much read-unfriendly . But I guess when you deal with a problem like webservices, the spec doc will be equally ugly.


Kamal Tripathi
SCJP 1.4 90%, SCWCD5 94%, Next SCDJWS--> In Naescent stage. Researching abt exam and material itself.
Ivan Krizsan
Ranch Hand

Joined: Oct 04, 2006
Posts: 2198
    
    1
Hi!
Kamal Tripathi wrote:
It is an anonymous complex type. How did it decide on a name for this complex type.

The complex type is not given a name, the element name ("OrderItems") found in the first <element> element in your XML schema snippet.
Note that "OrderItems" appear in a @XmlElement annotation ("element" being the keyword).
Best wishes!


My free books and tutorials: http://www.slideshare.net/krizsan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Doubt on the JAXB: XML Schema to Java mapping for anonymous complex type.