File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XJC generator

 
Luke Murphy
Ranch Hand
Posts: 300
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 300
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 649
3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 649
3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic