Re: [xml] ignore undefined entity references while parsing?

Yes, I have the  same question. And I read in the Xerces API documentation:


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.


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 =
            if (entity_reference_node_found(child))
                return true;
        return false;

int main()
        XercesDOMParser parser;
        cout << entity_reference_node_found(parser.getDocument()) << '\n';

with the next XML file:

<?xml version="1.0"?>
<!DOCTYPE test>

It will print 0. Why?

View this message in context:
Sent from the Gnome - Lib - Xml - General mailing list archive at

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]