Inheritance xsd模式元素的子元素是否继承了混合模式?

Inheritance xsd模式元素的子元素是否继承了混合模式?,inheritance,xsd,complextype,mixed,Inheritance,Xsd,Complextype,Mixed,混合复杂类型元素的子元素之间也可以有文本。 孩子们是否也继承了这个混合特性?换句话说,如果孩子不是混合型, 它们的子元素之间也可以有文本吗?否,混合的不会被子元素继承 给定此XSD: <?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="root"> <xs:complexType mixed="true"

混合复杂类型元素的子元素之间也可以有文本。 孩子们是否也继承了这个混合特性?换句话说,如果孩子不是混合型,
它们的子元素之间也可以有文本吗?

否,
混合的
不会被子元素继承

给定此XSD:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="root">
    <xs:complexType mixed="true">
      <xs:sequence>
        <xs:element name="child" minOccurs="0" maxOccurs="unbounded">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="grandchild" minOccurs="0" maxOccurs="unbounded">
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>
<root>
  text1
  <child>
    text2
    <grandchild/>
  </child>
</root>

此XML文档实例:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="root">
    <xs:complexType mixed="true">
      <xs:sequence>
        <xs:element name="child" minOccurs="0" maxOccurs="unbounded">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="grandchild" minOccurs="0" maxOccurs="unbounded">
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>
<root>
  text1
  <child>
    text2
    <grandchild/>
  </child>
</root>

文本1
文本2
将无效,因为
混合
内容模型未传递给
的内容模型

验证解析器将发出如下错误:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="root">
    <xs:complexType mixed="true">
      <xs:sequence>
        <xs:element name="child" minOccurs="0" maxOccurs="unbounded">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="grandchild" minOccurs="0" maxOccurs="unbounded">
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:sequence>
    </xs:complexType>
  </xs:element>
</xs:schema>
<root>
  text1
  <child>
    text2
    <grandchild/>
  </child>
</root>
元素“child”不能有字符[children],因为类型为 内容类型仅为元素

另请参见类似但不同的问题