aspose file tools*
The moose likes XML and Related Technologies and the fly likes XJC generator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XJC generator" Watch "XJC generator" New topic
Author

XJC generator

Luke Murphy
Ranch Hand

Joined: May 12, 2010
Posts: 300
Hi,
I have a very simple schema. Which has the following



When I generate the Person JAXB class using the XJC generator, I get a Java class named Person.

However, I don't want this class to be called Person. I want to call PersonXML or XPerson or something to indicate it is a Jaxb class.

What switch do I pass to XJC to achieve this?

Thanks

Luke Murphy
Ranch Hand

Joined: May 12, 2010
Posts: 300
At the moment I am just generating it and then renaming it. Just wondering if there was a more elegant solution.

Thanks.
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 544
    
    3
You can construct an external customization file (usually with extension .xjb, but that is not mandatory) in which you have an xpath pointing exactly to the specific place where the xsd define the element of name Persion. Since I can't be sure where it is, I suppose it is a top-level element. The .xjb file can look somewhat like this.

As to the compilation with xjc, use the switch -b to point to the .xjc. (Detail see xjc's documentation.)

You can also use inline annotation directly on the "yourSchema.xsd" without the external .xjb, but that would temper the schema which one may or may not like or be allowed to do so. Now that you've enough keyword, I'm sure you can google out for possible solution in that direction too if that's what you want.
g tsuji
Ranch Hand

Joined: Jan 18, 2011
Posts: 544
    
    3
amendment
Upon re-reading the schema, I would offer this amendment. Person would be generated as the class name, hence, it should rather be jxb:class instead of jxb:property.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: XJC generator