G
Georg J. Stach
Hi,
as mentioned above I'd like to validate a simple XML-document with a simple
DTD.
For this, I use Java and Xerces.
But, when I have tags of this form:
<tag>some characters in here</tag>
Xerces always complains with:
org.xml.sax.SAXParseException: s4s-elt-character: Non-whitespace characters
are not allowed in schema elements other than 'xs:appinfo' and
'xs:documentation'. Saw 'some characters in here'.
The XML-doc is this:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE durchwahlnummer SYSTEM "mydtd.dtd">
<mytag>123456</mytag>
------------
The DTD mydtd.dtd that:
<!ELEMENT mytag (#PCDATA)>
------------
As you can see, the mytag-tag is explicitly declared as PCDATA type, so the
error with "non-Whitespace characters" should actually not occur.
------------
The small Java-Program:
[..]
try {
DOMParser parser = new DOMParser();
parser.setErrorHandler(new ParserError());
parser.setFeature("http://xml.org/sax/features/validation", true);
parser.parse(myDocument);
doc = parser.getDocument();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SAXNotRecognizedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SAXNotSupportedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
[..]
------------
The DTD-validation is turned on.
(parser.setFeature("http://xml.org/sax/features/validation", true)
Does anyone know what's wrong and can help?
as mentioned above I'd like to validate a simple XML-document with a simple
DTD.
For this, I use Java and Xerces.
But, when I have tags of this form:
<tag>some characters in here</tag>
Xerces always complains with:
org.xml.sax.SAXParseException: s4s-elt-character: Non-whitespace characters
are not allowed in schema elements other than 'xs:appinfo' and
'xs:documentation'. Saw 'some characters in here'.
The XML-doc is this:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE durchwahlnummer SYSTEM "mydtd.dtd">
<mytag>123456</mytag>
------------
The DTD mydtd.dtd that:
<!ELEMENT mytag (#PCDATA)>
------------
As you can see, the mytag-tag is explicitly declared as PCDATA type, so the
error with "non-Whitespace characters" should actually not occur.
------------
The small Java-Program:
[..]
try {
DOMParser parser = new DOMParser();
parser.setErrorHandler(new ParserError());
parser.setFeature("http://xml.org/sax/features/validation", true);
parser.parse(myDocument);
doc = parser.getDocument();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SAXNotRecognizedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SAXNotSupportedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
[..]
------------
The DTD-validation is turned on.
(parser.setFeature("http://xml.org/sax/features/validation", true)
Does anyone know what's wrong and can help?