-1

If we say a DTD is satisfiable if there is a document which is valid against the DTD, is there any example of DTD which is not satisfiable?

C. M. Sperberg-McQueen
  • 24,596
  • 5
  • 38
  • 65
alex
  • 47
  • 6
  • Actually, XML documents conform to a DTD, not the other way round. A DTD cannot be said to "conform", since it is the place where a particular meaning of "conforming" is laid down in the form of rules. – Mathias Müller Sep 28 '14 at 14:44
  • This is like asking: we say a program is valid if the source conforms to the programming language, is there any example of programming language which is not valid? – slebetman Sep 28 '14 at 14:57
  • okay, let's say a DTD satisfiable if there is a document that conforms, do you have example DTD which is not satisfiable? – alex Sep 28 '14 at 15:01
  • @slebetman, yes, you're right: that's a lot like what is being asked here. And once we get past the OP's difficulty in formulating the question, it's equally interesting. Not particularly hard to answer, but interesting. Can we define a programming language which has no conforming programs? Or more generally: can we use BNF to define a language which has no sentences? Not everyone first encountering BNF, or programming-language specification tools, or DTDs, will find the answer obvious. – C. M. Sperberg-McQueen Oct 06 '14 at 18:42

1 Answers1

1

Interesting question (despite the OP's initial troubles finding good words for it).

The answer is: yes, there are DTDs which have no valid instances. Here are some examples.

(1) This DTD has no finite instances: each instance of element type e requires another instance of element type e.

<!ELEMENT e (e) >

This is an example of what alex, in a comment below, calls an infinite loop in the DTD.

(2) This DTD also lacks instances: each instance of type e requires an IDREF referring to an ID somewhere in the document, but no attributes of type ID are declared, so there cannot be any IDs to point at.

<!ELEMENT e ANY >
<!ATTLIST e ref IDREF #REQUIRED >

(3) This DTD also has no valid instances: each instance requires an f element, but no f element is declared.

<!ELEMENT e (f) >

Any DTD which contains no element declarations is also not satisfiable.

C. M. Sperberg-McQueen
  • 24,596
  • 5
  • 38
  • 65
  • and if infinite loop exists in the DTD, then there would be no XML conforms to that DTD, e.g. <!ELEMENT p(p+)>. – alex Oct 15 '14 at 23:16