How to rename a top level class name while generating JAXB code using XJC?

I am trying to create multiple beans from multiple xsd. Unfortunately, they all have the same root element. I have successfully created an xjc binding file to rename subelements, but cannot find a way to select the root node to change this.

I tried the following, but getting an error: [ERROR]. An XPath evaluation of "/" should 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>                                                           

+3
source share
1 answer

I get it.

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

+8
source

Source: https://habr.com/ru/post/1795546/


All Articles