在XML Schema中要求(允许)"xml:base" - 属性

vic*_*vic 6 xml xsd

给出如下文件:

<patch xmlns="http://example.com/ns/lxfs"
       xml:base="http:/example.com/publ/lxfs"
       id="http://example.com/lxfs/patches/3">

   <!-- ... -->
</patch>
Run Code Online (Sandbox Code Playgroud)

如何编写XML Schema以要求(甚至允许)xml:base具有固定值"http://example.com/publ/lxfs" 的属性的存在<patch>

这是我认为的"显而易见"的解决方案,但xs:attribute[@name]应该是NCName:

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:lxfs="http://example.com/ns/lxfs"
           xmlns:xml="http://www.w3.org/XML/1998/namespace"
           targetNamespace="http://example.com/ns/lxfs">

  <xs:element name="patch" type="lxfs:Patch" />

  <xs:complexType name="Patch">    
    <xs:attribute name="id" type="xs:anyURI" use="required" />
    <xs:attribute name="xml:base" form="qualified" fixed="http://example.com/publ/lxfs" use="required" />
  </xs:complexType>
</xs:schema>
Run Code Online (Sandbox Code Playgroud)

Mic*_*Kay 4

更改<xs:attribute name="xml:base"><xs:attribute ref="xml:base">,并为 XML 命名空间的架构添加 xs:import,该架构可在 中找到http://www.w3.org/2001/03/xml.xsd。(使用本地副本而不是对 W3C 上的副本的引用