Solved

Add elements in XML file not declared in the DTD

Posted on 2008-10-09
1
369 Views
Last Modified: 2008-10-15
I have created a DTD with the basic structure of my XML File. But my XML file can contain elements which are not declared in the DTD. How can i acheive this using DTD? Is there any tag in DTD with the help of which this can be acheived?


Suppose my DTD is 
 
<!ELEMENT subject (books, teachers) >
<!ELEMENT books (#PCDATA) >
<!ELEMENT teachers (#PCDATA) >
 
and my XML File is
 
<subject>
   <books>
      <book1 />
      <book2 />
   </books>
   <teachers />
</subject>
 
How can I acheieve this kind of functionality such that my DTD validates my XML file and gives no parsing error.

Open in new window

0
Comment
Question by:jdsiam
[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
1 Comment
 
LVL 60

Accepted Solution

by:
Geert Bormans earned 500 total points
ID: 22684618
You can't.
You could use XML Schema.
There you can tell that the content of an element can be anything and that the validation should be "lax" for that part.
With DTD you can't achieve that.
0

Featured Post

Technology Partners: 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

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
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.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

691 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