How do I rename top level Classname during JAXB code generation using XJC?
I am trying to generate some beans from several xsd's. Unfortunately they all have the same root element. I have successfully created a xjc bindings file for renaming sub-elements but cannot find开发者_JAVA技巧 a way to select the root node to change that.
I tried the following but get the error: [ERROR] XPath evaluation of "/" needs to result in an element.
<jxb:bindings version="1.0" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:com.fnf="http://www.fnf.com/xes">
<jxb:bindings schemaLocation="transcode-submit.xsd" node="/xs:schema">
<jxb:bindings node="/">
<jxb:property name="Newname"/>
</jxb:bindings>
</jxb:bindings>
I figured it out.
<jxb:bindings version="1.0" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:com.fnf="http://www.fnf.com/xes">
<jxb:bindings schemaLocation="transcode-submit.xsd" node="/xs:schema">
<jxb:bindings node="//xs:element[@name='OLDROOTNAME']">
<jxb:class name="NEWNAME"/>
</jxb:bindings>
精彩评论