?
Solved

DTD validation problems

Posted on 2008-10-15
4
Medium Priority
?
384 Views
Last Modified: 2013-12-15
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?
0
Comment
Question by:kayahr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 2000 total points
ID: 22720440
I am afraid that eclipse is right

Problem 1:
To avoid ambiguity in mixed content elements, this is the only way that is allowed to define mixed content
<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT parent ( #PCDATA  | child1 | child2)*>
<!ELEMENT child1 (#PCDATA)>
<!ELEMENT child2 (#PCDATA)>
Note that this is more relaxed than what you originally had, but this is the only way

It would also allow
<parent>bla bla <child2/> blabla <child1/> bla bla <child2/> blabla ...
not exactly what you want,
but there is no other way
If you really need to use DTD and limit to your example you will have to add an extra validation layer, eg. using XSLT
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 22720481
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
0
 
LVL 7

Author Comment

by:kayahr
ID: 22720902
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).
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 22720928
welcome
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Jaspersoft Studio is a plugin for Eclipse that lets you create reports from a datasource.  In this article, we'll go over creating a report from a default template and setting up a datasource that connects to your database.
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question