相关疑难解决方法(0)

不合格的XSD全局属性引用

以下XML模式无法使用以下XML实例文档进行验证.有没有办法重写模式,以便实例文档在给定的约束内验证?

约束

  • 该属性不能是元素的本地属性
  • 实例文档必须保持不变

(无效)架构

<?xml version="1.0" encoding="utf-8"?>
<xs:schema targetNamespace="http://tempuri.org/XMLSchema.xsd"
    elementFormDefault="qualified"
    xmlns="http://tempuri.org/XMLSchema.xsd"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <xs:attribute name="sample-attribute" type="xs:string" />

    <xs:element name="sample-element">
        <xs:complexType>
            <xs:attribute ref="sample-attribute" use="required" />
        </xs:complexType>
    </xs:element>
</xs:schema>
Run Code Online (Sandbox Code Playgroud)

<?xml version="1.0" encoding="utf-8"?>
<sample-element xmlns="http://tempuri.org/XMLSchema.xsd" sample-attribute="test" />
Run Code Online (Sandbox Code Playgroud)

xml xsd xml-namespaces

4
推荐指数
2
解决办法
2431
查看次数

标签 统计

xml ×1

xml-namespaces ×1

xsd ×1