Hello,
I have the following XML file (snippet) and the corresponding DTD.
Please note that I want to use namespaces in the XML file:
-----------------------------------------------------------
XML file:
<?xml version="1.0" standalone="no"?>
<!DOCTYPE Skat:Turnier SYSTEM "F:\development\xml_projekt\SkatTurnier.DTD">
<Skat:Turnier xmlns:Skat=" xmlns="gsch.default/"
AnzahlRunden="3">
[...]
-------------------------------------------------------------
Corresponding DTD:
<!ELEMENT Skat:Turnier (Skatatum?,
Skat:SpielOrt?,
Skat:Spieler*)>
<!ATTLIST Skat:Turnier AnzahlRunden CDATA #REQUIRED>
[...]
-------------------------------------------------------------
As long as I do not use a validating parser all works fine, and the SAX callback methods startElement() and endElement() indicate that namespace:element is handled correctly.
However, once I turn on validation, the parser throws the following error message, complaining that the "xmlns:..." attribute has not been declared for element Skat:Turnier.
XML file being parsed: F:\development\xml_projekt\skat3110.xml
* setDocumentLocator() was called.
Parsing started....
**Parsing-Error**
Line: 5
URI: file:/f:/development/xml_projekt/skat3110.xml
Message: Attribute "xmlns:Skat" must be declared for element type "Skat:Turnier".
I know there are some limitations/restrictions concerning DTD and namespaces. Can anyone tell me where my problem is? This is the code snippet that turns on validation.
The parser is Xerces 1.4.3.
try {
XMLReader parser =
XMLReaderFactory.createXMLReader(
"org.apache.xerces.parsers.SAXParser"
parser.setContentHandler(contentHandler);
parser.setErrorHandler(errorHandler);
// turn on validation
parser.setFeature(" true );
parser.parse(uri);
}
Any help is really appreciated.
Thanks,
Gunnar Schmitz
I have the following XML file (snippet) and the corresponding DTD.
Please note that I want to use namespaces in the XML file:
-----------------------------------------------------------
XML file:
<?xml version="1.0" standalone="no"?>
<!DOCTYPE Skat:Turnier SYSTEM "F:\development\xml_projekt\SkatTurnier.DTD">
<Skat:Turnier xmlns:Skat=" xmlns="gsch.default/"
AnzahlRunden="3">
[...]
-------------------------------------------------------------
Corresponding DTD:
<!ELEMENT Skat:Turnier (Skatatum?,
Skat:SpielOrt?,
Skat:Spieler*)>
<!ATTLIST Skat:Turnier AnzahlRunden CDATA #REQUIRED>
[...]
-------------------------------------------------------------
As long as I do not use a validating parser all works fine, and the SAX callback methods startElement() and endElement() indicate that namespace:element is handled correctly.
However, once I turn on validation, the parser throws the following error message, complaining that the "xmlns:..." attribute has not been declared for element Skat:Turnier.
XML file being parsed: F:\development\xml_projekt\skat3110.xml
* setDocumentLocator() was called.
Parsing started....
**Parsing-Error**
Line: 5
URI: file:/f:/development/xml_projekt/skat3110.xml
Message: Attribute "xmlns:Skat" must be declared for element type "Skat:Turnier".
I know there are some limitations/restrictions concerning DTD and namespaces. Can anyone tell me where my problem is? This is the code snippet that turns on validation.
The parser is Xerces 1.4.3.
try {
XMLReader parser =
XMLReaderFactory.createXMLReader(
"org.apache.xerces.parsers.SAXParser"
parser.setContentHandler(contentHandler);
parser.setErrorHandler(errorHandler);
// turn on validation
parser.setFeature(" true );
parser.parse(uri);
}
Any help is really appreciated.
Thanks,
Gunnar Schmitz