Details
-
Bug
-
Status: Closed
-
Resolution: Fixed
-
1.4
-
None
-
None
-
Operating System: Linux
Platform: All
-
1150
Description
[This was already mentioned on xerces-c-dev]
Given these files
==> sample.dtd <==
<?xml version="1.0" encoding="ISO-8859-1"?>
<!ELEMENT spam:sample EMPTY>
<!ATTLIST spam:sample
xmlns:spam CDATA #FIXED "http://www.cinetic.de/2000/"
>
==> sample.xml <==
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE spam:sample SYSTEM "sample.dtd">
<spam:sample/>
==> sample2.dtd <==
<?xml version="1.0" encoding="ISO-8859-1"?>
<!ELEMENT spam:sample EMPTY>
<!ATTLIST spam:sample xmlns:spam CDATA #REQUIRED>
==> sample2.xml <==
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE spam:sample SYSTEM "sample2.dtd">
<spam:sample xmlns:spam="http://www.cinetic.de/2000/"/>
I get this behaviour (using plain Xerces 1.4):
--> DOMPrint -v=always sample.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE spam:sample SYSTEM "sample.dtd">
<spam:sample xmlns:spam="http://www.cinetic.de/2000/"/>
--> DOMPrint -v=always -n sample.xml
An error occured during parsing
Message:
[this is a DOMException : 14 (NAMESPACE_ERR)]
--> DOMPrint -v=always sample2.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE spam:sample SYSTEM "sample2.dtd">
<spam:sample xmlns:spam="http://www.cinetic.de/2000/"/>
--> DOMPrint -v=always -n sample2.xml
Error at file "/export/home/jhe/tmp/sample2.xml", line 3, column 56
Message: Required attribute 'xmlns:spam' was not provided
An error occured during parsing
The only way to get this working is to never mention the xmlns:spam
attribute in the DTD and just use it in the root element. Is this
what I should expect? AFAIR, the XHTML specs use #FIXED attributes in
the DTD for the namespace, and that would not work with Xerces.
Xerces 1.3:
jhe@lxdev70:~/tmp > DOMPrint-1.3 -v=always sample.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE spam:sample SYSTEM "sample.dtd">
<spam:sample xmlns:spam="http://www.cinetic.de/2000/"/>
jhe@lxdev70:~/tmp > DOMPrint-1.3 -v=always -n sample.xml
An error occured during parsing
Message:
jhe@lxdev70:~/tmp > DOMPrint-1.3 -v=always sample2.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE spam:sample SYSTEM "sample2.dtd">
<spam:sample xmlns:spam="http://www.cinetic.de/2000/"/>
jhe@lxdev70:~/tmp > DOMPrint-1.3 -v=always -n sample2.xml
Error at file "/export/home/jhe/tmp/sample2.xml", line 3, column 56
Message: Required attribute 'xmlns:spam' was not provided
An error occured during parsing
Xerces 1.2:
jhe@lxdev70:~/tmp > DOMPrint-1.2 -v=always sample.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE spam:sample SYSTEM "sample.dtd">
<spam:sample xmlns:spam="http://www.cinetic.de/2000/"/>
jhe@lxdev70:~/tmp > DOMPrint-1.2 -v=always -n sample.xml
Fatal Error at file "/export/home/jhe/tmp/sample.xml", line 3, column
15
Message: The prefix 'spam' has not been mapped to any URI
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE spam:sample SYSTEM "sample.dtd">
jhe@lxdev70:~/tmp > DOMPrint-1.2 -v=always sample2.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE spam:sample SYSTEM "sample2.dtd">
<spam:sample xmlns:spam="http://www.cinetic.de/2000/"/>
jhe@lxdev70:~/tmp > DOMPrint-1.2 -v=always -n sample2.xml
Error at file "/export/home/jhe/tmp/sample2.xml", line 3, column 56
Message: Required attribute 'xmlns:spam' was not provided
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE spam:sample SYSTEM "sample2.dtd">
And even these two errors are not justified, IMHO.