Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/8.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
Xml xsd模式-强制关系_Xml_Xsd_Schema - Fatal编程技术网

Xml xsd模式-强制关系

Xml xsd模式-强制关系,xml,xsd,schema,Xml,Xsd,Schema,我使用.xsd模式验证了以下xml 我可以强制xProfile中的每个产品名称都存在,并通过使用ref和key ref在xml的前半部分中定义 我想强制要求每个“xProduct”都包含xml上半部分中定义的每个产品的一个条目,但不知道如何做到这一点,或者这是否可行 <?xml version="1.0" encoding="UTF-8"?> <profiles xmlns:xsi="http://www.w3.org/2001/XMLSchema-instan

我使用.xsd模式验证了以下xml

我可以强制xProfile中的每个产品名称都存在,并通过使用ref和key ref在xml的前半部分中定义

我想强制要求每个“xProduct”都包含xml上半部分中定义的每个产品的一个条目,但不知道如何做到这一点,或者这是否可行

    <?xml version="1.0" encoding="UTF-8"?>
    <profiles xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"         xsi:noNamespaceSchemaLocation="\\schema.xsd">
        <products>
            <product name="product01" bool_setting="true">
                <code name="AAA"/>
                <code name="BBB"/>
            </product>
            <product name="product02" bool_setting="true">
                <code name="CCC"/>
                <code name="DDD"/>
            </product>
            <product name="product03" bool_setting="true">
                <code name="EEE"/>
            </product>
            <product name="product04" bool_setting="false">
                <code name="FFF"/>
                <code name="GGG"/>
            </product>
            <product name="product05" bool_setting="false">
                <code name="HHH"/>
            </product>
            <product name="product06" bool_setting="false">
                <code name="III"/>
            </product>
        </products>
        <xProfile name="name_one">
            <products>
                <product name="product01" aNumber="1"/>
                <product name="product02" aNumber="1"/>
                <product name="product03" aNumber="1"/>
                <product name="product04" aNumber="1"/>
                <product name="product05" aNumber="1"/>
                <product name="product06" aNumber="1"/>
            </products>
        </xProfile>
            <xProfile name="name_one">
            <products>
                <product name="product01" aNumber="1"/>
                <product name="product02" aNumber="1"/>
                <product name="product03" aNumber="1"/>
                <product name="product04" aNumber="1"/>
                <product name="product05" aNumber="1"/>
                <product name="product06" aNumber="1"/>
            </products>
        </xProfile>
    </profiles>

请将您的模式粘贴到此处,否则很难找到。 否则,有两种方法可以限制此操作: 在XML中使用派生,一种是扩展派生,另一种是限制派生,如下所示:

目前,本例的模式没有包含任何内容。我不知道为什么这会影响如何强制执行我想要的约束?