JAXB 2.1 - Customize xs:any binding

前端 未结 1 2023
北荒
北荒 2021-01-02 19:53

I want to generate java code from xsd using JAXB 2.1 XJC. I have an xsd schema provided and I can\'t change it. I would like to use xjc:simple mode while ge

相关标签:
1条回答
  • 2021-01-02 20:28

    You can use the Wildcard plugin from JAXB2 Basics. This allows you to customize lax/skip/strict wildcard binding modes:

    <?xml version="1.0"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
        xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
        xmlns:wildcard="http://jaxb2-commons.dev.java.net/basic/wildcard"
        jaxb:version="2.1"
        jaxb:extensionBindingPrefixes="wildcard">
    
    ...
    
        <xs:complexType name="issueJIIB10Type" mixed="true">
            <xs:annotation>
                <xs:appinfo>
                    <wildcard:lax/>
                </xs:appinfo>
            </xs:annotation>
            <xs:complexContent mixed="true">
                <xs:extension base="xs:anyType"/>
            </xs:complexContent>
        </xs:complexType> 
    
    ...
    
    </xs:schema>
    

    You don't have to change the schema for this, you can use this customization via binding files.

    0 讨论(0)
提交回复
热议问题