?
Solved

Add elements in XML file not declared in the DTD

Posted on 2008-10-09
1
Medium Priority
?
374 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 1500 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

The Orion Papers

Are you interested in becoming an AWS Certified Solutions Architect?

Discover a new interactive way of training for the exam.

Question has a verified solution.

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

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.
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

752 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