給定一個文件,如以下幾點:要求(允許)「的xml:基地」的XML Schema -attribute
<patch xmlns="http://example.com/ns/lxfs"
xml:base="http:/example.com/publ/lxfs"
id="http://example.com/lxfs/patches/3">
<!-- ... -->
</patch>
如何編寫一個XML Schema要求(甚至允許)的存在屬性與<patch>
上的「http://example.com/publ/lxfs」的固定值有關?
這是我會考慮的「明顯」的解決方案,但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>