[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Entity references
Hi List, I have a question that is actually more xml related but maybe still relevant here. I'm working on a system that processes xml with stylesheets. Some incoming pakages do not have an accessable DTD, so we can't validate against that. We would like to catch some events/mistakes/errors though like undeclared entity references. This works in the case where there is no DTD in the XML. When there is a reasoble DTD however, we don't get any error messages. Can anyone explain this? code for DocumentBuilder (to see what features/options are used) DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); try { // needed to not resolve dtd location etc factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); DocumentBuilder builder = factory.newDocumentBuilder().parse(inputStream); } catch (ParserConfigurationException ex) { throw new XmlException("Failed to set feature on non validating document builder factory.", ex); } Below reports (also without partial DTD declaration): [Fatal Error] :5:41: The entity "referenced-but-not-declared" was referenced, but not declared. <?xml version="1.0"?> <!DOCTYPE Aap > <Entity> <Reference> <Illegal>&referenced-but-not-declared;</Illegal> </Reference> </Entity> No report of undeclared entity reference <?xml version="1.0"?> <!DOCTYPE Aap PUBLIC "noot" "http://mies"> <Entity> <Reference> <Illegal>&referenced-but-not-declared;</Illegal> </Reference> </Entity> To be sure we DO want the error message also when DTD is declared. factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); I expect to ignore DTD, so there would be an error reported.... Parser seems to be Xerces, probably Java's standard build in one. Thanx and regards, Michel Hendriksen
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|