开发者

generation of java classes from xsd using jaxb

开发者 https://www.devze.com 2023-03-14 06:07 出处:网络
Currently working on a project in which the xsd\'s have been provided for data exchange. The xsd\'s are available isotc211. As can be seen there are a couple of them and i am interested in generation

Currently working on a project in which the xsd's have been provided for data exchange. The xsd's are available isotc211. As can be seen there are a couple of them and i am interested in generation of classes for /gmd/metadataEntity.xsd which in turn has dependencies on other xsds and so on. The problem is that there is a lot of repetition of names for elements and attributes and it would be a really long job to get rid of them and at the end i am not even sure if it will work. i have this till now ..

<jxb:bindings version="2.0" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 xmlns:jxb="http://java.sun.com/xml/ns/jaxb" >         
<jxb:bindings schemaLocation="geometryPrimitives.xsd" node="/xsd:schema">           
 <jxb:schemaBindings>  
         <jxb:package name="net.opengis.gml"/>     
            <jxb:nameXmlTransform>       
               <jxb:elementName suffix="Element"/>     
            </jxb:nameXmlTransform>     
      </jxb:schemaBindings>     
   <jxb:bindings
    node="//xsd:group[@name='PointGrid']/xsd:sequence/xsd:element[@name='rows']">
<jxb:property name="rowsElement"/>
</jxb:bindings>    
</jxb:bindings>    
</jxb:bindings>`

the namexml transform was supposed to help to t开发者_如何学编程ake care of the element and attributes naming but i still have a lot of similary naming across the xsd's. is there a way of getting around this ? For instance elements are now generated using the suffix. so i get net.open.gml.SecondDefiningParameterElement is already in use.

when something like this exists in one of the xsd's

<element name="secondDefiningParameter"><complexType>
        <sequence>
            <element ref="gml:SecondDefiningParameter"/>
        </sequence>
    </complexType>
</element>

and in the same xsd

<element name="SecondDefiningParameter">
    <complexType>
        <choice>
            <element name="inverseFlattening" type="gml:MeasureType"/>
            <element name="semiMinorAxis" type="gml:LengthType"/>
            <element name="isSphere">
                <simpleType>
                    <restriction base="string">
                        <enumeration value="sphere"/>
                    </restriction>
                </simpleType>
            </element>
        </choice>
    </complexType>
</element>
0

精彩评论

暂无评论...
验证码 换一张
取 消