我试图从几个xsd生成一些bean.不幸的是,它们都具有相同的根元素.我已成功创建了一个xjc绑定文件,用于重命名子元素,但无法找到一种方法来选择根节点来更改它.
我尝试了以下但得到错误:[错误] XPath评估"/"需要导致一个元素.
<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>
Run Code Online (Sandbox Code Playgroud)
我想到了.
<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>
Run Code Online (Sandbox Code Playgroud)