3

我正在尝试从几个 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>                                                           

4

1 回答 1

8

我想到了。

<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>

于 2011-03-01T17:00:25.657 回答