permaculture playing cards
The moose likes Product and Other Certifications and the fly likes Internal DTD & External DTD Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Product and Other Certifications
Bookmark "Internal DTD & External DTD" Watch "Internal DTD & External DTD" New topic

Internal DTD & External DTD

Siva shanmugam

Joined: Jul 18, 2002
Posts: 15
Can anyone tell me,
Is it is possible to redefine the elements in Internal DTD subset which are already defined in external DTD subset ?
External DTD file ex1.dtd is like this
<!ELEMENT eleName (#PCDATA)>

Xml file is like this
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<!DOCTYPE eleName SYSTEM "ex1.dtd"
<!ELEMENT eleName (childElement1|childElement2)*>
] >
This above code works fine in IE 6.0
but it gives, Element type "eleName" must not be declared more than once
Error in Xerces Parser.
Dean Jones

Joined: Jun 18, 2002
Posts: 24
hmmmm u cant declare a element already defined in the external DTD in the internal DTD.The MSXML parser with the IE is not fuly compliant with the standards bu Xalan wil not leave u ,that is the Resaon dear
Samir Shah

Joined: Sep 19, 2002
Posts: 11
XML paresers implementations vary for this.
According to W3 Specs.
1) No ELEMENT can be declared twice.
2) ATTRIBUTE can be declared more than once BUT only first ATTRIBUTE declaration is binding. If two ATTLIST is defined for an ELEMENT, attribute definations will be merged (i.e. new attributes defined in subsequent ATTLIST will be added to ATTLIST)
3) ENTITY can be declared more than once BUT only First ENTITY declaration is binding.
4) Only one notation declaration can declare a given Name
jim yin
Ranch Hand

Joined: Aug 15, 2002
Posts: 111
Originally posted by Samir Shah:
1) No ELEMENT can be declared twice.

I still have a doubt for this. In PXML2 (p138), it says:

...the external subset description of an element might allow several child elements, while the internal subset version specifies an empty element. Any XML data containing this DTD combination had better use an empty element, or it would be considered invalid.

Does that mean it does not allow to declare an element twice in the same subset, but allow to declare it twice in an internal and an external subsets since the internal one can override the external one? Any thoughts?
Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1183
Samir is absolutely right about the four points he made.
It seems to me that the only construct in the DTD that can be redefined is the parameter entity.

William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
Vasudha Deepak
Ranch Hand

Joined: Mar 15, 2002
Posts: 86
Yes an Element can only be defined once,considering both the internal and the external DTD.
In the following example the element1 has been defined both in the external and internal DTD.However a DTD/Schema error appears in XML Spy stating the the element1 has been defined already.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE root SYSTEM "test.dtd" [
<!ELEMENT root (element1)>
<!ELEMENT element1 (#PCDATA)>

<?xml version="1.0" encoding="UTF-8"?>
<!ELEMENT element1 (#PCDATA)>


IBM Certified Developer -XML and Related Technologies(141)<br />SCJP2 SCWCD
Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1183
Samir said -
3) ENTITY can be declared more than once BUT only First ENTITY declaration is binding.

Please note that the internal DTD subset is read _first_. This allows us to redefine an entity, which was originally defined in the external subset, in the internal subset.
Dan Drillich
Ranch Hand

Joined: Jul 09, 2001
Posts: 1183
The same applies for attributes as well.
I agree. Here's the link:
subject: Internal DTD & External DTD
jQuery in Action, 3rd edition