Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JAXB-重写元素的数据类型_Jaxb - Fatal编程技术网

JAXB-重写元素的数据类型

JAXB-重写元素的数据类型,jaxb,Jaxb,我将JAXB与以下定制绑定一起使用: <jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" version="2.0" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" jaxb:extensionBindingPrefixes="xjc" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <jaxb:globalBin

我将JAXB与以下定制绑定一起使用:

<jaxb:bindings xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" version="2.0" xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" jaxb:extensionBindingPrefixes="xjc" xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <jaxb:globalBindings typesafeEnumMaxMembers="2000">
        <jaxb:serializable />
    </jaxb:globalBindings>
        <jaxb:bindings schemaLocation="test.xsd" node="/xs:schema//xs:complexType[@name='EN']//xs:element[@name='family']">
            <jaxb:property>
                <jaxb:baseType name="java.lang.String" />
            </jaxb:property>
        </jaxb:bindings>
</jaxb:bindings>
我的绑定文件怎么了? 它是关于
jaxb:property
的,但是当删除后者时,不会发生重写


任何帮助都将非常感谢,提前感谢各位

我很幸运地将
jxb:bindings节点
标记嵌套在
jxb:bindings schemaLocation
标记中,如下所示:

<?xml version="1.0" encoding="US-ASCII" ?>
<jxb:bindings version="2.0" 
    xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
    xmlns:jxb="http://java.sun.com/xml/ns/jaxb" 
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"
>

    <jxb:bindings schemaLocation="test.xsd"> 
        <jxb:bindings node="//xs:element[@name='family']">
            <jxb:property >
                <jxb:baseType name="java.lang.String"></jxb:baseType>
            </jxb:property>
        </jxb:bindings>
    </jxb:bindings>
</jxb:bindings>

此外:

  • 虽然你对“家庭”的注释有效,但它似乎过于复杂。我根据您的示例xsd将其更新为一个可以工作的元素(只要只有一个元素名为class='family',它就可以工作)
我也尝试过这样做:但我得到了相同的错误“编译器无法接受此javaType自定义”
[ERROR] compiler was unable to honor this property customization. It is attached to a wrong place, or its inconsistent with other bindings.
  line 6 of file://home/user/test/jaxbelem_binding.xml

[ERROR] (the above customization is attached to the following location in the schema)
  line 7 of file://home/user/test/test.xsd

Failed to parse a schema.
<?xml version="1.0" encoding="US-ASCII" ?>
<jxb:bindings version="2.0" 
    xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
    xmlns:jxb="http://java.sun.com/xml/ns/jaxb" 
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"
>

    <jxb:bindings schemaLocation="test.xsd"> 
        <jxb:bindings node="//xs:element[@name='family']">
            <jxb:property >
                <jxb:baseType name="java.lang.String"></jxb:baseType>
            </jxb:property>
        </jxb:bindings>
    </jxb:bindings>
</jxb:bindings>