Mark VY
Mark VY

Reputation: 1673

Reference another XML file from DTD

Suppose I have an XML file colors.xml

<colors>
    <color id="white" value="#FFFFFF" />
    <color id="black" value="#000000" />
    <!-- 100+ colors omitted -->
</colors>

In another file I'm defining a DTD, with something like this

<!ELEMENT prettyPicture EMPTY>
<!ATTLIST prettyPicture
    fg NMTOKEN <!-- fore ground color -->
    bg NMTOKEN <!-- back ground color -->
>

Since fg and bg are specified as NMTOKEN, they can be pretty much anything. Is there an easy way to insist that they must be colors as listed in colors.xml?

Upvotes: 0

Views: 38

Answers (1)

Michael Kay
Michael Kay

Reputation: 163549

Simple answer: no, unless you get into programmatic construction of the DTD. In fact, even with XSD, which is much more powerful, you would need to do some code generation to make this work - though with XSD it's much more feasible as it's all XML.

Upvotes: 1

Related Questions