JAXB separate episodes with annox customizations fails : SAXParseException2

≯℡__Kan透↙ 提交于 2019-12-01 23:09:41

There is a bug using annox and episodes.

I've solved the same issue through external binding (xjb file). In this way the schema is also clean.

e.g.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxb:bindings
  xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:annox="http://annox.dev.java.net"
  xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"
  jaxb:extensionBindingPrefixes="xjc annox"
  version="2.1">

  <jaxb:globalBindings>
    <jaxb:serializable uid="12345"/> 
  </jaxb:globalBindings>


  <jaxb:bindings schemaLocation="domain1.xsd" node="/xs:schema">
    <jaxb:bindings node="xs:complexType[@name='SomeRootType']">
      <annox:annotate>
        <annox:annotate annox:class="javax.xml.bind.annotation.XmlRootElement" name="SomeRootType"/>
      </annox:annotate>
    </jaxb:bindings>
  </jaxb:bindings>

</jaxb:bindings>

this is the maven plugin configuration

<plugin>
        <groupId>org.jvnet.jaxb2.maven2</groupId>
        <artifactId>maven-jaxb2-plugin</artifactId>
        <version>0.8.1</version>
        <executions>
            <execution>
                <phase>generate-sources</phase>
                <goals>
                    <goal>generate</goal>
                </goals>
            </execution>
        </executions>
        <configuration>
            <args>
                <arg>-Xannotate</arg>
                <arg>-Xnamespace-prefix</arg>
                <arg>-nv</arg>
            </args>
            <extension>true</extension>
            <forceRegenerate>true</forceRegenerate>
            <bindingDirectory>${basedir}/src/main/resources/schema/xjb</bindingDirectory>
            <bindingIncludes>
                <include>*.xjb</include>
            </bindingIncludes>
            <schemas>
                <schema>
                    <fileset>
                        <directory>${basedir}/src/main/resources/schema/project/b</directory>
                        <includes>
                            <include>*.xsd</include>
                        </includes>
                    </fileset>
                </schema>
                <schema>
                    <dependencyResource>
                        <groupId>com.project.a</groupId>
                        <artifactId>artifact.a</artifactId>
                        <resource>schema/a.xsd</resource>
                    </dependencyResource>
                </schema>
            </schemas>
            <episodes>
                <episode>
                    <groupId>com.project.a</groupId>
                    <artifactId>artifact.a</artifactId>
                </episode>
            </episodes>
            <debug>true</debug>
            <verbose>true</verbose>
            <plugins>
                <plugin>
                    <groupId>org.jvnet.jaxb2_commons</groupId>
                    <artifactId>jaxb2-basics</artifactId>
                    <version>0.6.2</version>
                </plugin>
                <plugin>
                    <groupId>org.jvnet.jaxb2_commons</groupId>
                    <artifactId>jaxb2-basics-annotate</artifactId>
                    <version>0.6.2</version>
                </plugin>
                <plugin>
                    <groupId>org.jvnet.jaxb2_commons</groupId>
                    <artifactId>jaxb2-namespace-prefix</artifactId>
                    <version>1.1</version>
                </plugin>
            </plugins>
        </configuration>
    </plugin>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!