[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Entity references

Subject: [xsl] Entity references
From: Michel Hendriksen <michel.hendriksen@xxxxx>
Date: Fri, 4 Jan 2013 15:00:12 +0100

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
            DocumentBuilder builder =
        } 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"?>

No report of undeclared entity reference

<?xml version="1.0"?>
<!DOCTYPE Aap PUBLIC "noot" "http://mies">

To be sure we DO want the error message also when DTD is declared.
false); I expect to ignore DTD, so there would be an error

Parser seems to be Xerces, probably Java's standard build in one.

Thanx and regards,

Michel Hendriksen

Current Thread