C# 使用属性验证架构

C# 使用属性验证架构,c#,xml,validation,xsd,schema,C#,Xml,Validation,Xsd,Schema,我有以下xml: <Root> <SomethingA/> <SomethingB/> <SomethingC/> <SomeOtherThing action="Foo"> <Bar/> <Bar/> </SomeOtherThing> <SomeOtherThing action="Poo">

我有以下xml:

<Root>
    <SomethingA/>
    <SomethingB/>
    <SomethingC/>
    <SomeOtherThing action="Foo">
        <Bar/>
        <Bar/>
    </SomeOtherThing>
    <SomeOtherThing action="Poo">
        <BarFoo/>
        <BarNoo/>
    </SomeOtherThing>
</Root>

我想创建一个模式,它将验证如果元素是其他东西,那么如果操作是Foo,那么子元素只能是Bar;如果动作是Poo,那么子元素可以是BarFoo(和/或)BarNoo

关于如何实现它(仅使用xsd)有什么想法吗


此外,解决方案需要在C#上工作。

这种条件验证不能在XSD 1.0中完成。可以在XSD 1.1中使用名为“条件类型分配”的功能来完成此操作。

更新问题的可能重复项。我只关心xsd验证解决方案。不过还是要谢谢你。有没有办法在VisualStudio中使用XSD1.1?(2010/2012)无论我在哪里看到都没有对它的支持(编辑问题)XSD1.1目前在Saxon(9.4)和ApacheXerces(beta)中受支持。我知道还有其他未经宣布的处理器正在开发中(但不是来自微软)。微软似乎不再有兴趣让他们的XML产品与W3C标准保持同步。