File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes XML and Related Technologies and the fly likes Extending DTD Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Extending DTD" Watch "Extending DTD" New topic

Extending DTD

Vijay Venkat
Ranch Hand

Joined: Aug 12, 2001
Posts: 52

Can any one point me to some documents/examples or let me know how i can extend a DTD to add new elements and attributes?

Vijay V
Balaji Loganathan
author and deputy

Joined: Jul 13, 2001
Posts: 3150
The best startup... - DTD tutorial
Vijay Venkat
Ranch Hand

Joined: Aug 12, 2001
Posts: 52
Hi Balaji - Thanks for the Link.

I probably didn't phrase my question right.

I want to know how to Extend a DTD. If someone has already published a DTD and there are few place holders in the DTD where in certain elements allow its child to be of TYPE ANY. In this case i can add new elements there. But ANY in DTD means any element that is already defined in the DTD.
While ANY in schema means a new element, which need not be already declared in the scheam.

So if there is a DTD which has an element say CHEMICAL and has child by name CHEMICAL-EXTENSION which is of type ANY, now in this child element
CHEMICAL-EXTENSION - I want to add new elements which is not defined by the current DTD.

How can i do this. What is the recomended way to do it.

Vijay Venkat
Lasse Koskela

Joined: Jan 23, 2002
Posts: 11962
I haven't done this myself, ever, but I think you should look into the following approach:

1) Leave the existing DTD as it is.
2) Create a new DTD document where you define your new elements.
3) Add an ENTITY reference to the original DTD file...
...and import it into the new DTD file:

Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Vijay Venkat
Ranch Hand

Joined: Aug 12, 2001
Posts: 52
Hi Lasse Koskela,
I am back after a break.
Thanks a lot for your response. I will try and let you know how it works.

Vijay Venkat
I agree. Here's the link:
subject: Extending DTD
It's not a secret anymore!