[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Entity references

Subject: Entity references
From: Michel Hendriksen <michel.hendriksen@xxxxx>
Date: Fri, 4 Jan 2013 15:00:12 +0100
 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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.