Xml XSD 1.1-发现以元素';开头的内容无效;xs:备选方案';

Xml XSD 1.1-发现以元素';开头的内容无效;xs:备选方案';,xml,xsd,phpstorm,xsd-validation,xsd-1.1,Xml,Xsd,Phpstorm,Xsd Validation,Xsd 1.1,在我的XSD中,我试图使用alternative标记。由于某些原因,我在IDE(PHPStorm)中遇到此错误: 以元素“xs:alternative”开头的内容无效 XSD <xs:complexType name="tableType"> <xs:sequence> <xs:element type="columnType" name="column" maxOccurs="unbounded" minOccurs="0"/>

在我的XSD中,我试图使用
alternative
标记。由于某些原因,我在IDE(PHPStorm)中遇到此错误:

以元素“xs:alternative”开头的内容无效

XSD

<xs:complexType name="tableType">
    <xs:sequence>
        <xs:element type="columnType" name="column" maxOccurs="unbounded" minOccurs="0"/>
        <xs:element type="keyType" name="key" maxOccurs="unbounded" minOccurs="0">
            <xs:alternative test="@type='index'" type="keyIndexType"/>
            <xs:alternative test="@type='unique'" type="KeyUniqueType"/>
        </xs:element>
    </xs:sequence>
    <xs:attribute type="xs:string" name="name" use="required"/>
</xs:complexType>


我看到了,但是我需要支持
alternative
标记吗?

为了使用
xs:alternative
(),您的XSD处理器必须支持XSD 1.1XSD 1.0处理器将不允许
xs:alternative
作为
xs:element
的子元素,并将提供一条错误消息,如您收到的错误消息。因此,您可以得出结论,您的XSD处理器只支持XSD 1.0


有关CTA的工作示例,请参见(当然,这也需要XSD 1.1)。

多亏了@kjhughes,我找到了解决方案。 我不得不从XSD1.0处理器切换到XSD1.1处理器

在PHPstorm中:设置面板>语言和框架>默认XML Shemas

注意:要“应用”更改,必须重新启动PHPStorm


在我的例子中,XSD处理器链接到PHPStorm?是的。您可以尝试,但您可能会发现,这种配置只允许您根据模式的XSD1.1模式验证XSD1.1文档本身;它可能不会实际调用XSD 1.1处理器来针对实例XML文档启用XSD 1.1验证。也许PHPStorm用户或JetBrains员工可以肯定地说。