Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.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
maxoccurs的XSD验证限制_Xsd_Xsd Validation - Fatal编程技术网

maxoccurs的XSD验证限制

maxoccurs的XSD验证限制,xsd,xsd-validation,Xsd,Xsd Validation,嗨,我有这种XML 我想编写一个验证此数据的XML: <?xml version="1.0" encoding="UTF-8"?> <Entry attribute1="value1" attribute2="Value2"> <subEntry tagX="xValue1" tagy="yValue"/> </Entry> 但这并不能证明 <?xml version="1.0" encoding="UTF-8"?> &l

嗨,我有这种XML

我想编写一个验证此数据的XML:

<?xml version="1.0" encoding="UTF-8"?>
<Entry attribute1="value1" attribute2="Value2">
    <subEntry tagX="xValue1" tagy="yValue"/>
</Entry>

但这并不能证明

<?xml version="1.0" encoding="UTF-8"?>
<Entry attribute1="value1" attribute2="Value2">
    <subEntry tagX="xValue1" tagy="yValue"/>
    <subEntry tagX="xValue1" tagy="yValue"/>
</Entry>

我想限制子条目的数量:

序列的maxOccurs不检查子项的数量

XSD是:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
    <xs:element name="Entry">
        <xs:complexType>
            <xs:sequence>
                <xs:element ref="subEntry"/>
            </xs:sequence>
            <xs:attribute1 name="dateEmission" type="xs:dateTime" use="required"/>
            <xs:attribute2 name="emetteur" type="xs:string" use="required"/>
        </xs:complexType>
    </xs:element>
    <xs:element name="Entry">
        <xs:complexType>
            <xs:attribute name="tagX" type="xs:string" use="required"/>
            <xs:attribute name="tagy" type="xs:decimal" use="optional"/>
        </xs:complexType>
    </xs:element>
</xs:schema>

您需要在元素声明中添加maxOccurs。把它改成下面的

<xs:sequence>
     <xs:element ref="subEntry" maxOccurs="1" />
</xs:sequence>