XJC:从无效方案生成 JAXB 类

XJC: generate JAXB classes from invalid scheme

我想生成一组 JAXB 注释 classes of the OGC IndoorGML XML scheme (http://schemas.opengis.net/indoorgml/1.0/indoorgmlcore.xsd)

所以我运行 xjc -d scr -p [packagename] -nv [path_to_xsd](-nv 抑制输入方案的严格验证)

但是 运行执行此命令会导致以下错误消息:

[ERROR] Property "Rows" is already defined. Use <jaxb:property> to resolve this conflict.
  line 653 of http://schemas.opengis.net/gml/3.2.1/geometryPrimitives.xsd

[ERROR] The following location is relevant to the above error
  line 685 of http://schemas.opengis.net/gml/3.2.1/geometryPrimitives.xsd

[ERROR] Property "Title" is already defined. Use <jaxb:property> to resolve this conflict.
  line 261 of http://www.w3.org/1999/xlink.xsd

[ERROR] The following location is relevant to the above error
  line 246 of http://www.w3.org/1999/xlink.xsd

[ERROR] Property "Title" is already defined. Use <jaxb:property> to resolve this conflict.
  line 232 of http://www.w3.org/1999/xlink.xsd

[ERROR] The following location is relevant to the above error
  line 219 of http://www.w3.org/1999/xlink.xsd

和 class 文件未生成。这很奇怪,因为我希望这些“官方”方案是正确的。

但是,还有什么方法可以生成忽略这些错误的 java classes 吗?

经过反复试验并基于this xjb binding file,此命令行将生成代码

xjc -d src -XautoNameResolution -b indoor.xjb -nv indoorgmlcore.xsd

未使用包名称,添加了 -XautoNameResolution 并删除了一些扩展。 xjb 文件中的注释表示对原始 xjb 添加的更改。使用了最新的 version of xsd

indoor.xjb内容:

<jaxb:bindings version="1.0" 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"
    jaxb:extensionBindingPrefixes="xjc">
    <!--
    xmlns:wildcard="http://jaxb2-commons.dev.java.net/basic/wildcard"
    xmlns:annox="http://annox.dev.java.net"
    -->

    <jaxb:bindings schemaLocation="http://schemas.opengis.net/gml/3.2.1/gml.xsd" 
        node="/xs:schema">
        <jaxb:schemaBindings>
            <jaxb:package name="net.opengis.gml.v_3_2"/>
        </jaxb:schemaBindings>
    </jaxb:bindings>

    <jaxb:bindings schemaLocation="http://schemas.opengis.net/gml/3.2.1/geometryPrimitives.xsd" node="/xs:schema">
        <jaxb:bindings>
            <jaxb:bindings node="//xs:group[@name='PointGrid']/xs:sequence/xs:element[@name='rows']">
                <!-- ** Backwards incompatible -->
                <jaxb:property name="PointGridRows"/>
            </jaxb:bindings>
        </jaxb:bindings>
    </jaxb:bindings>

<!-- Whosebug 68692723 question -->
    <jaxb:bindings schemaLocation="http://www.w3.org/1999/xlink.xsd" node="/xs:schema">
        <jaxb:bindings>
            <jaxb:bindings node="//xs:element[@name='title']">
                <jaxb:property name="XTitle"/>
            </jaxb:bindings>
        </jaxb:bindings>
    </jaxb:bindings>

    <jaxb:bindings schemaLocation="http://schemas.opengis.net/gml/3.2.1/coordinateOperations.xsd">
        <jaxb:bindings node="//xs:element[@name='parameterValue']">
            <jaxb:factoryMethod name="xparameterValue"/>
        </jaxb:bindings>
        <jaxb:bindings node="//xs:element[@name='operationParameter']">
            <jaxb:factoryMethod name="xoperationParameter"/>
        </jaxb:bindings>
        <jaxb:bindings node="//xs:element[@name='OperationParameter']">
            <jaxb:factoryMethod name="XOperationParameter"/>
        </jaxb:bindings>
    </jaxb:bindings>
<!-- Whosebug 68692723 question END -->

    <jaxb:bindings schemaLocation="http://schemas.opengis.net/gml/3.2.1/grids.xsd" node="/xs:schema">
        <jaxb:bindings>
            <jaxb:bindings node="xs:complexType[@name='GridType']/xs:complexContent/xs:extension/xs:sequence/xs:choice/xs:element[@name='axisLabels']">
                <!-- ** Backwards incompatible -->
                <jaxb:property name="GridAxisLabels"/>
            </jaxb:bindings>
        </jaxb:bindings>
    </jaxb:bindings>
        

    <jaxb:bindings schemaLocation="http://schemas.opengis.net/gml/3.2.1/datums.xsd" node="/xs:schema">
        <jaxb:bindings>
            <jaxb:bindings node="//xs:element[@name='secondDefiningParameter']">
                <jaxb:class name="SecondDefiningParameterPropertyElement"/>
            </jaxb:bindings>
            <jaxb:bindings node="//xs:element[@name='ellipsoid']">
                <jaxb:factoryMethod name="EllipsoidPropertyElement"/>
            </jaxb:bindings>
            <jaxb:bindings node="//xs:element[@name='primeMeridian']">
                <jaxb:factoryMethod name="PrimeMeridianPropertyElement"/>
            </jaxb:bindings>
        </jaxb:bindings>
    </jaxb:bindings>

    <jaxb:bindings schemaLocation="http://schemas.opengis.net/gml/3.2.1/coordinateReferenceSystems.xsd" node="/xs:schema">
        <jaxb:bindings>
            <jaxb:bindings node="//xs:element[@name='userDefinedCS']">
                <jaxb:factoryMethod name="UserDefinedCSPropertyElement"/>
            </jaxb:bindings>
            <jaxb:bindings node="//xs:element[@name='cartesianCS']">
                <jaxb:factoryMethod name="CartesianCSPropertyElement"/>
            </jaxb:bindings>
            <jaxb:bindings node="//xs:element[@name='sphericalCS']">
                <jaxb:factoryMethod name="SphericalCSPropertyElement"/>
            </jaxb:bindings>
            <jaxb:bindings node="//xs:element[@name='polarCS']">
                <jaxb:factoryMethod name="PolarCSPropertyElement"/>
            </jaxb:bindings>
            <jaxb:bindings node="//xs:element[@name='linearCS']">
                <jaxb:factoryMethod name="LinearCSPropertyElement"/>
            </jaxb:bindings>
            <jaxb:bindings node="//xs:element[@name='verticalCS']">
                <jaxb:factoryMethod name="VerticalCSPropertyElement"/>
            </jaxb:bindings>
            <jaxb:bindings node="//xs:element[@name='cylindricalCS']">
                <jaxb:factoryMethod name="CylindricalCSPropertyElement"/>
            </jaxb:bindings>
            <jaxb:bindings node="//xs:element[@name='ellipsoidalCS']">
                <jaxb:factoryMethod name="EllipsoidalCSPropertyElement"/>
            </jaxb:bindings>
            <jaxb:bindings node="//xs:element[@name='affineCS']">
                <jaxb:factoryMethod name="AffineCSPropertyElement"/>
            </jaxb:bindings>
            <jaxb:bindings node="//xs:element[@name='timeCS']">
                <jaxb:factoryMethod name="TimeCSPropertyElement"/>
            </jaxb:bindings>

            <jaxb:bindings node="//xs:element[@name='imageDatum']">
                <jaxb:factoryMethod name="ImageDatumPropertyElement"/>
            </jaxb:bindings>
            <jaxb:bindings node="//xs:element[@name='geodeticDatum']">
                <jaxb:factoryMethod name="GeodeticDatumPropertyElement"/>
            </jaxb:bindings>
            <jaxb:bindings node="//xs:element[@name='temporalDatum']">
                <jaxb:factoryMethod name="TemporalDatumPropertyElement"/>
            </jaxb:bindings>
            <jaxb:bindings node="//xs:element[@name='engineeringDatum']">
                <jaxb:factoryMethod name="EngineeringDatumPropertyElement"/>
            </jaxb:bindings>
            <jaxb:bindings node="//xs:element[@name='verticalDatum']">
                <jaxb:factoryMethod name="VerticalDatumPropertyElement"/>
            </jaxb:bindings>
            <jaxb:bindings node="//xs:element[@name='conversion']">
                <jaxb:factoryMethod name="ConversionPropertyElement"/>
            </jaxb:bindings>
        </jaxb:bindings>
    </jaxb:bindings>
</jaxb:bindings>

以下错误已根据 this page

修复

[ERROR] Two declarations cause a collision in the ObjectFactory class. line 243 of http://schemas.opengis.net/gml/3.2.1/coordinateOperations.xsd