Java 混合和受限元素无法通过Xmlbeans验证

Java 混合和受限元素无法通过Xmlbeans验证,java,xsd,xmlbeans,xmlspy,Java,Xsd,Xmlbeans,Xmlspy,在使用Xmlbeans时,我注意到,当一个元素被定义为来自混合类型的限制时,如果该元素中有一些文本,Xmlbeans验证将失败。但是,如果在XmlSpy中针对模式验证运行相同的xml文件,则该文件是有效的。下面是一个例子(我试着让它尽可能简单): xml架构: <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualif

在使用Xmlbeans时,我注意到,当一个元素被定义为来自混合类型的限制时,如果该元素中有一些文本,Xmlbeans验证将失败。但是,如果在XmlSpy中针对模式验证运行相同的xml文件,则该文件是有效的。下面是一个例子(我试着让它尽可能简单):

xml架构:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
    <xs:element name="RootElement">
        <xs:annotation>
            <xs:documentation>Comment describing your root element</xs:documentation>
        </xs:annotation>
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="Child"/>
                <xs:element ref="ChildExtended"/>
                <xs:element ref="ChildRestricted"/>
            </xs:sequence>
        </xs:complexType>
    </xs:element>
    <xs:element name="Child" type="MixedType"/>
    <xs:element name="ChildRestricted" type="MixedTypeRestricted"/>
    <xs:element name="ChildExtended" type="MixedTypeExtended"/>
    <xs:complexType name="MixedType" mixed="true"/>
    <xs:complexType name="MixedTypeExtended" mixed="true">
        <xs:complexContent mixed="true">
            <xs:extension base="MixedType"/>
        </xs:complexContent>
    </xs:complexType>
    <xs:complexType name="MixedTypeRestricted" mixed="true">
        <xs:complexContent mixed="true">
            <xs:restriction base="MixedType"/>
        </xs:complexContent>
    </xs:complexType>
</xs:schema>

描述根元素的注释
xml文件:

<RootElement xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <Child>text</Child> 
    <ChildExtended>text1</ChildExtended>
    <ChildRestricted>text2</ChildRestricted>
</RootElement>

正文
文本1
文本2
对于XmlSpy,这是有效的。以下是使用Xmlbeans进行验证时得到的结果:

Message: Element 'ChildRestricted' with empty content type cannot have text or element content.
Location of invalid XML: <xml-fragment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
消息:内容类型为空的元素“ChildRestricted”不能包含文本或元素内容。
无效XML的位置:

正如您所看到的,导致问题的只是定义为受限类型的子级。我的问题是:谁是对的?XmlSpy(无错误)或Xmlbeans?

正如您在创建的问题中所评论的,修复了该问题