开发者

How do I rename top level Classname during JAXB code generation using XJC?

开发者 https://www.devze.com 2023-02-14 16:55 出处:网络
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开发

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>

0

精彩评论

暂无评论...
验证码 换一张
取 消