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)*> ] > <eleName/> 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.
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
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
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?
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. test.xml <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE root SYSTEM "test.dtd" [ <!ELEMENT root (element1)> <!ELEMENT element1 (#PCDATA)> ]> <root> <element1/> </root>