2014-01-10 113 views

回答

1

不,mixed不是由子元素继承。

鉴于这种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> 

此XML文档实例:

<root> 
    text1 
    <child> 
    text2 
    <grandchild/> 
    </child> 
</root> 

将是无效因为rootmixed内容模型是不是一起的内容传递型号为child

验证解析器将发出一个错误,如下列:

元素“孩子”不能有字符[儿童],因为该类型的 内容类型的元素而已。

又见相似,但不同的问题Is mixed inherited when a complexType is extended?