1

我想生成一组 OGC IndoorGML XML 方案的 JAXB 注释类(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

并且没有生成类文件。这很奇怪,因为我希望这些“官方”计划是正确的。

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

4

1 回答 1

1

经过一些试验和错误并基于此 xjb 绑定文件,此命令行将生成代码

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

没有使用包名称,-XautoNameResolution添加并删除了一些扩展。文件中的注释xjb表示添加到原始xjb. 使用了最新版本的 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>

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

基于此页面修复的错误如下

[错误] 两个声明导致 ObjectFactory 类中的冲突。http://schemas.opengis.net/gml/3.2.1/coordinateOperations.xsd的第 243 行

于 2021-08-07T19:12:41.967 回答