I'm writing an XML document and trying to also state its specification.
I think that I can specify that the attribute of a tag can limited to an attribute of another tag, and I think that can be done using the !ATTLIST
's IDREF
, but I'm not too sure. Example:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE CUSTOM_RIBBON
[
<!ELEMENT CUSTOM_RIBBON (VERSION, ICONS, SCRIPT+, CMD_ID+, CATEGORY)>
<!ELEMENT ICONS (#CDATA)>
<!ELEMENT SCRIPT (#CDATA)>
<!ELEMENT CMD_ID (SPEC)>
<!ELEMENT CATEGORY (PANEL)>
<!ELEMENT PANEL (BUTTON, GROUP, SEPARATOR)+>
<!ELEMENT GROUP (BUTTON, SEPARATOR)+>
<!ELEMENT BUTTON EMPTY>
<!ATTLIST BUTTON name IDREF #REQUIRED>
<!ELEMENT SEPARATOR EMPTY>
<!ELEMENT VERSION EMPTY>
<!ATTLIST VERSION value CDATA #REQUIRED>
]>
<CUSTOM_RIBBON>
<SCRIPT name="button1-script">
// some script here
messagebox("AHHH!");
</SCRIPT>
<CMD_ID name="button1">
<SPEC pressed="both" script="button1-script" text="boo!" />
</CMD>
<CATEGORY name="Foo">
<PANEL name="Bar">
<BUTTON name="button1" />
</PANEL>
</CATEGORY>
<CUSTOM_RIBBON>
I'd like to specify that:
BUTTON
tag must have an attribute name
that must have the same text in a CMD_ID
tag's name
attribute.CMD-ID
tag has a script
attribute that must have the same text in a SCRIPT
tag's name
attribute.CMD_ID
's SPEC
has a pressed
attribute of both
, then it can't have a sibling.CMD_ID
's SPEC
has a pressed
attribute of true
or false
, then it must have a sibling that is false
or true
.How can I accomplish this?
Looks like it can't be done with DTD. I will have to go with XSD instead.