XML模式:在xs:sequence中使用minOccurs和maxOccurs
给定有效的XSD:XML模式:在xs:sequence中使用minOccurs和maxOccurs,xml,xsd,xsd-validation,xml-validation,Xml,Xsd,Xsd Validation,Xml Validation,给定有效的XSD: <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="personinfo"> <xs:complexType> <xs:sequence maxOccurs="2"> <xs
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="personinfo">
<xs:complexType>
<xs:sequence maxOccurs="2">
<xs:element name="firstname" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="lastname" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
为什么它到现在仍然有效?不要minOccurs
和maxOccurs
只需通过xs:sequence
覆盖maxOccurs
不要minOccurs
和maxOccurs
只需通过xs:sequence
覆盖maxOccurs
否,封闭的xs:sequence
上的出现约束意味着组本身可以按照指定一起出现或重复。包含单个元素的对象上的引用约束会单独影响这些元素,而与这些元素的集合可能发生的方式无关
对于XSD,可以有一个或两个序列,每个序列都有firstname
(可选)和lastname
(必需)
不要minOccurs
和maxOccurs
只需通过xs:sequence
覆盖maxOccurs
否,封闭的xs:sequence
上的出现约束意味着组本身可以按照指定一起出现或重复。包含单个元素的对象上的引用约束会单独影响这些元素,而与这些元素的集合可能发生的方式无关
对于XSD,可以有一个或两个序列,每个序列都有firstname
(可选)和lastname
(必需)
<personinfo>
<firstname>lalal</firstname>
<lastname>fwfw</lastname>
<firstname>lalal</firstname>
<lastname>fwfw</lastname>
</personinfo>