質問

I have XML like this:

    <?xml version="1.0" encoding="utf-8"?>
    <Records xmlns="...">
        <Some>
            ...
            <Records>
                <Record>
                </Record>
            </Records>
        </Some>
    </Records>

I generate XDS and after that generate classes:

xjc some.xsd

So, i have following structure:

duplicate

How to solve this problem?

役に立ちましたか?

解決

You can use an external binding file to rename the class generated from a complex type. Below is an example where the class corresponding to the complex type itemType would be generated as Item.

<jxb:bindings 
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
    version="2.1">

    <jxb:bindings schemaLocation="your-schema.xsd">
            <jxb:bindings node="//xs:complexType[@name='itemType']">
                <jxb:class name="Item"/>
            </jxb:bindings>
    </jxb:bindings>

</jxb:bindings>

You specify the binding file in the XJC call using the -b flag

xjc -b binding.xml your-schema.xsd
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top