// is not null, if so, report an error.
DocumentType docType = node.getOwnerDocument().getDoctype();
if (docType != null) {
NamedNodeMap entities = docType.getEntities();
for (int i = 0; i < entities.getLength(); i++) {
Entity ent = (Entity) entities.item(i);
String nodeName =
node.getNodeName() == null ? "" : node.getNodeName();
String nodeNamespaceURI =
node.getNamespaceURI() == null
? ""
: node.getNamespaceURI();
String entName =
ent.getNodeName() == null ? "" : ent.getNodeName();
String entNamespaceURI =
ent.getNamespaceURI() == null ? "" : ent.getNamespaceURI();
// If referenced in Element content
// WFC: Parsed Entity
if (parent.getNodeType() == Node.ELEMENT_NODE) {
if (entNamespaceURI.equals(nodeNamespaceURI)
&& entName.equals(nodeName)) {
if (ent.getNotationName() != null) {
String msg =
Utils.messages.createMessage(
MsgKey.ER_WF_REF_TO_UNPARSED_ENT,
new Object[] { node.getNodeName()});
if (fErrorHandler != null) {
fErrorHandler.handleError(
new DOMErrorImpl(
DOMError.SEVERITY_FATAL_ERROR,
msg,
MsgKey.ER_WF_REF_TO_UNPARSED_ENT,
null,
null,
null));
}
}
}
} // end if WFC: Parsed Entity
// If referenced in an Attr value
// WFC: No External Entity References
if (parent.getNodeType() == Node.ATTRIBUTE_NODE) {
if (entNamespaceURI.equals(nodeNamespaceURI)
&& entName.equals(nodeName)) {
if (ent.getPublicId() != null
|| ent.getSystemId() != null
|| ent.getNotationName() != null) {
String msg =
Utils.messages.createMessage(
MsgKey.ER_WF_REF_TO_EXTERNAL_ENT,
new Object[] { node.getNodeName()});