1

I want to generate a set of JAXB annotated classes of the OGC IndoorGML XML scheme (http://schemas.opengis.net/indoorgml/1.0/indoorgmlcore.xsd)

So I run xjc -d scr -p [packagename] -nv [path_to_xsd] (the -nv suppresses the strict validation of input schemes)

But running this command results in the following error messages:

[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

and the class files are not being generated. This is strange, because I would expect these "official" schemes to be correct.

However, is there still any way to generate the java classes ignoring these errors?

Fabian
  • 85
  • 5
  • It looks like you're somehow loading the same schema twice. If you take two copies of a valid schema and combine them, the result is an invalid schema because of the duplicates. But I don't know JAXB well enough to help you. – Michael Kay Aug 07 '21 at 16:03
  • @MichaelKay Okay, thank you anyway. No, the problem really seems to be in the scheme ("rows" is defined twice in one file, see the mentioned lines) – Fabian Aug 07 '21 at 17:40

1 Answers1

1

After some trial and error and based on this xjb binding file, this command line will generate code

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

No package name is used, -XautoNameResolution is added and some extensions were removed. Comments inxjb file denote changes added to the original xjb. Latest version of xsd was used.

indoor.xjb contents:

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

Errors as below where fixed based on 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

LMC
  • 10,453
  • 2
  • 27
  • 52