创建XJC文件,jaxb自定义文件

时间:2014-08-08 12:32:21

标签: xml jaxb xsd customization xjc

如何生成.XJC文件或jaxb自定义文件?

Goggled但找不到任何工具。试过XML间谍但不能 提前致谢

1 个答案:

答案 0 :(得分:1)

这是一个xjb示例..

<bindings version="2.0" xmlns="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"
    xmlns:annox="http://annox.dev.java.net">
    <bindings schemaLocation="../your.xsd">

            <bindings node="//xs:complexType[@name='YourType']">
                <annox:annotate>
                    <annox:annotate annox:class="javax.xml.bind.annotation.XmlRootElement"
                        name="YourType" namespace="http://name.space.xsd">
                    </annox:annotate>
                </annox:annotate>
            </bindings>

            <bindings node="//xsd:complexType[@name='User']//xsd:sequence//xsd:element[@name='certificate']">
                <xjc:javaType name="java.security.cert.X509Certificate" adapter="adapters.X509CertificateAdapter" />
            </bindings>

    </bindings>
</bindings>