That's because it's undefined; as I wrote, that is an error, and Xerces does not supports creating a reference to a non-existent entity.

Alberto

Igor Ignatyuk wrote:
Hi Alberto,

Thank you. I added setting "entities" to "true", but the program prints 0 as
before:


#include <iostream>
using namespace std;

#include <xercesc/dom/DOMConfiguration.hpp>
#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");
        DOMDocument const* const document = parser.getDocument();
        document->getDOMConfig()->setParameter(L"entities", true);
        cout << entity_reference_node_found(document) << '\n';
    }
    XMLPlatformUtils::Terminate();
}


Igor


Reply via email to