Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/13.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
使用xmllint进行XML模式验证:抱怨诸如<;foobar/>;_Xml_Validation_Xsd_Schema_Xmllint - Fatal编程技术网

使用xmllint进行XML模式验证:抱怨诸如<;foobar/>;

使用xmllint进行XML模式验证:抱怨诸如<;foobar/>;,xml,validation,xsd,schema,xmllint,Xml,Validation,Xsd,Schema,Xmllint,我在使用xmllint验证XSD架构的XML文件时遇到问题:xmllint与一个有效性错误相比较,即类似的标记不是预期的,尽管在XSD架构中定义了如下foobar: <xs:element name="foobar" minOccurs="0"> <xs:simpleType> <xs:restriction base="xs:positiveInteger"> <xs:minInclusive value

我在使用
xmllint
验证XSD架构的XML文件时遇到问题:xmllint与一个有效性错误相比较,即类似
的标记不是预期的,尽管在XSD架构中定义了如下
foobar

<xs:element name="foobar" minOccurs="0">
    <xs:simpleType>
        <xs:restriction base="xs:positiveInteger">
            <xs:minInclusive value="1"/>
            <xs:maxInclusive value="9999"/>
        </xs:restriction>
    </xs:simpleType>
</xs:element>

p.p.S.:xmllint版本20901

数字或正常值可以是正整数或空字符串

下面是可能的解决方案,否则应使用
nillable=“true”


数字或正常值可以是正整数或空字符串。这用于集合元素的内容。

您在模式中说过,元素的值必须是1到9999之间的整数,但元素的实际值是空内容。我不太明白为什么你的模式不允许这个值

如果要允许此范围内的整数或空内容,有两种可能的方法:

(a) 定义一个联合类型,其成员类型为(i)1到9999范围内的整数,以及(ii)具有facet
length=0的字符串,或

(b) 定义一个列表类型,其项目类型为1到9999之间的整数,列表类型具有
minLength=0
maxLength=1

您也可以使用
nillable=“true”
,但是
不是有效的内容,它必须是
,这(在我看来)完全违背了目的

myfile.xml:135298: element foobar: Schemas validity error : Element '{http://www.foobaz.com/namespace}foobar': '' is not a valid value of the local atomic type.
<xs:simpleType name="positive-integer-or-empty">
    <xs:annotation>
        <xs:documentation>The number-or-normal values can be either a positive integer or an empty string. This is used for the content of the ensemble element.</xs:documentation>
    </xs:annotation>
    <xs:union memberTypes="positive-integer-restricted">
        <xs:simpleType>
            <xs:restriction base="xs:string">
                <xs:enumeration value=""/>
            </xs:restriction>
        </xs:simpleType>
    </xs:union>
</xs:simpleType>
<xs:simpleType name="positive-integer-restricted">
    <xs:restriction base="xs:positiveInteger">
        <xs:minInclusive value="1"/>
        <xs:maxInclusive value="9999"/>
    </xs:restriction>
</xs:simpleType>