In your test program you are not setting the "entities" property to "true"

Alberto

igna wrote:
Hi,

I read in the Xerces API documentation:

"entities" true [required] Keep EntityReference and Entity nodes in the document.
false [required] (default) Remove all EntityReference and Entity nodes from
the document, putting the entity expansions directly in their place. Text
nodes are into "normal" form. Only EntityReference nodes to non-defined
entities are kept in the document. (http://xerces.apache.org/xerces-c/apiDocs-3/classDOMConfiguration.html)

Therefore entity reference nodes to undefined entities should be kept in the
document. But try the next program:

#include <iostream> using namespace std; #include <xercesc/dom/DOMNode.hpp> #include <xercesc/parsers/XercesDOMParser.hpp> #include <xercesc/util/PlatformUtils.hpp> using namespace xercesc; namespace { bool entity_reference_node_found(DOMNode const* const node) { if (DOMNode::ENTITY_REFERENCE_NODE == node->getNodeType()) return true; for (DOMNode const* child = node->getFirstChild(); child; child = child->getNextSibling()) if (entity_reference_node_found(child)) return true; return false; } } int main() { XMLPlatformUtils::Initialize(); { XercesDOMParser parser; parser.parse("undefined_entity.xml"); cout << entity_reference_node_found(parser.getDocument()) << '\n'; } XMLPlatformUtils::Terminate(); }

with the next XML file:

<?xml version="1.0"?> <!DOCTYPE test> <test>&abcd;</test>

It will print 0. Why?


Reply via email to