On Thu, 29 Jun 2000, Thomas Gelzhaeuser wrote:
> I'm just a bloody beginner in XML and joined therefore this group here in hope of some help:
> I want to write a DTD for a simple directed graph. My first approach to it looks like that:
> <!ELEMENT net (node|edge)+>
> <!ELEMENT node (#PCDATA)>
> <!ATTLIST node id ID #REQUIRED>
> <!ELEMENT edge (#PCDATA)>
> <!ATTLIST edge id ID #REQUIRED>
Fine so far.
> <!ATTLIST edge startnode #PCDATA #REQUIRED>
> <!ATTLIST edge targetnode #PCDATA #REQUIRED>
#PCDATA isn't allowed as an attribute type.
> My question: Is it possible to make shure somehow in the DTD that as startnode and targetnode for each edge only values can be taken, where there are also nodes with that id have been defined in the same file?
If you changed the type of those attributes to IDREF, a validating parser
would enforce the constraint that any value assigned to them appear as the
ID attribute of some other element. However, since both <node>s and
<edge>s have ID attributes, you would *not* be able to use the DTD to
enforce the constraint that the values identify <node>s but not
<edge>s; there's no way to partition IDs into separate classes using a DTD
and AFAIK there's no way to do it with the W3C's schema proposal
either. You *could* use something like Schematron to enforce such