Link to home
Start Free TrialLog in
Avatar of kayahr
kayahrFlag for Germany

asked on

DTD validation problems

I'm using the DTD editor which is integrated in Eclipse 3.4.1 and I stumbled over a DTD in our system which Eclipse doesn't accept (But which seems to work in the system where it is used). I'm not very familar with DTDs and now I wonder if there are really DTD problems (which are ignored for some reason when it is used on the production system) or if the validator in Eclipse is buggy. So can you please check a few lines. Please note: I'm trying to validate the DTD, not the XML files.

Problem 1:

<!ELEMENT parent (child1?, child2?, #PCDATA)>
<!ELEMENT child1 (#PCDATA)>
<!ELEMENT child2 (#PCDATA)>

It should allow an XML document like this:

<parent>
  <child1>data<child1>
  <child2>data<child2>
  Some text data
</parent>

Validator doesn't like the #PCDATA in the first line (Error message: A '(' character or an element type is required in the declaration of element type "parent".). So first question: Is this not allowed in a DTD? Or is this a false alarm in Eclipse? Or can I write this in a different way which may be accepted by Eclipse?


Problem 2:

<!ATTLIST mail contentType  (text/plain | text/html) "text/plain" >

This should allow a "mail" element with an optional contentType attribute which can have the values "text/plain" and "text/html". But Eclipse doesn't like the slash in the values (Error message: "The enumerated type list must end with ')' in the "contentType" attribute declaration."). Again: Is this not allowed in a DTD or is it an Eclipse bug? Or can I solve this in a different way which makes Eclipse happy and still works?
ASKER CERTIFIED SOLUTION
Avatar of Gertone (Geert Bormans)
Gertone (Geert Bormans)
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Problem 2
if you have an enumerated list of attribute values, there are limitations to the characters that are allowed (should be NMTOKEN I believe) A '/' is not an allowed character in such a list
If you really need that value, I suggest that you use XML Schema instead of DTD

I don't know which parser you have been using before, but it is obviously not a good one
Avatar of kayahr

ASKER

I digged a little bit deeper and found out that this DTD is not used at all. It's only "parsed" by humans... Oh I hate my job sometimes. I have renamed the file into a txt file and added a comment that someone may want to convert it into a XML schema and then start to really use it...

Thanks for the help. I'm happy that it's really a buggy DTD and not an Eclipse bug (Because I like to keep using Eclipse for validation).