我需要创建 DTD 或 XMLSchema。如何将元素 collection@key="role" 与 collection@key="tie" 联系起来?这是可能的还是需要在不同的元素中完成?
我有 XML
<!DOCTYPE schema [
<!ELEMENT schema (collection+, part+)>
<!ELEMENT collection[key=role] (name, partref+)>
<!ATTLIST collection[key=role] collection-id ID #REQUIRED
key CDATA #REQUIRED>
<!ELEMENT name (#PCDATA)>
<!ELEMENT partref EMPTY>
<!ATTLIST partref refid IDREF #REQUIRED>
<!ELEMENT collection[key=tie] (name)>
<!ATTLIST collection[key=tie] part-id ID #REQUIRED>
]>
<schema>
<collection collection-id="C28392-33-TT" key="role">
<name>Turnip Twaddler</name>
<partref refid="P81952-26-PK"/>
<partref refid="P86679-52-SP"/>
<partref refid="P81472-68-FD"/>
<partref refid="P88107-39-GT"/>
</collection>
<collection collection-id="C28772-63-OB" key="role">
<name>Olive Bruiser</name>
<partref refid="P80228-21-PT"/>
<partref refid="P82387-85-PA"/>
</collection>
<part part-id="P80228-21-PT">
<name>Pitter</name>
</part>
<collection part-id="P86994-25-RC" key="tie">
<name>Ribbon Curler</name>
</collection>
</schema>