Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/36.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
Xsd 断言某些元素独立于顺序而存在于其他元素之间_Xsd - Fatal编程技术网

Xsd 断言某些元素独立于顺序而存在于其他元素之间

Xsd 断言某些元素独立于顺序而存在于其他元素之间,xsd,Xsd,我正在从如下构建的xml提要导入数据: <?xml version="1.0" encoding="utf-8"?> <channel> <item> <a>some data</a> <b>some data</b> <c>some data</c> </item> <item> <c>some data&l

我正在从如下构建的xml提要导入数据:

<?xml version="1.0" encoding="utf-8"?>
<channel>
  <item>
    <a>some data</a>
    <b>some data</b>
    <c>some data</c>
  </item>
  <item>
    <c>some data</c>
    <d>some data</d>
    <b>some data</b>
  </item>
</channel>

一些数据
一些数据
一些数据
一些数据
一些数据
一些数据
只有一些数据对我很重要——在上面的示例中,让我们假设元素
中的数据

下一项可能包含名为
,或者为什么不
的标记。除了我感兴趣的标记名之外,其他标记名我都不知道,并且可能随时出现

对于我来说,使用xsd有什么方法可以验证我感兴趣的元素(
)是否存在于所有


谢谢

如果您有xsd,您可以解释该元素是必需的

例如

    <xs:complexType name="item">
        <xs:all>
            <xs:element name="a" type="xs:string" minOccurs="0"/>
            <xs:element name="b" type="xs:string" minOccurs="1"/>
            <xs:element name="c" type="xs:string" minOccurs="1"/>
            <xs:element name="d" type="xs:string" minOccurs="0"/>
        </xs:all>
    </xs:complexType>

这样,您应该只应用xsd验证

  • 独立于订单
  • minOccurs=“1”
    必填元素

我希望我已经给了你关于你问题的所有答案。

你解决了这个问题吗?不是我想要的方式。我使用了和你下面建议的相同的方法。重点是——我不知道所有可用项目的名称。然而,我把这个标记为答案,因为这是我最后做这件事的方式。这种方法的问题是,当我正在验证的提要以我实际上不感兴趣的方式进行更改时(比如添加元素e),我必须更新我的xsd。