Hey,

I've been wrestling with printing out the values of Entities defined
in the internal subset of the DOCTYPE. I've discovered that to get the
info I need to have setCreateEntityReferenceNodes(TRUE). I would love
to know where this is documented anywhere in Xerces. And what do
entity reference nodes have to do with this? I'm retrieving data from
the doctype, not asking for the entities used in the document, or
maybe I'm confused about what entity reference nodes really are... 

This does create a text node that is the child of the entity node,
with the value of the entity. Why doesn't getNodeValue() retrieve the
value? This would seem like a logical extension of how it works for
other node types.

my code produces this output with setCreateEntityReferenceNodes(FALSE):
Got Entity name: gt; value: ; Has subnodes: 0
Got Entity name: lt; value: ; Has subnodes: 0
Got Entity name: amp; value: ; Has subnodes: 0
Got Entity name: apos; value: ; Has subnodes: 0
Got Entity name: data; value: ; Has subnodes: 0
Got Entity name: quot; value: ; Has subnodes: 0

and with setCreateEntityReferenceNodes(TRUE):
Got Entity name: gt; value: ; Has subnodes: 0
Got Entity name: lt; value: ; Has subnodes: 0
Got Entity name: amp; value: ; Has subnodes: 0
Got Entity name: apos; value: ; Has subnodes: 0
Got Entity name: data; value: ; Has subnodes: 1
        Got Child name: #text; value: DATA; Has subnodes: 0
Got Entity name: quot; value: ; Has subnodes: 0

Also, what about the default entities, why aren't their values
present even if I include them in the document?

Thanks,
jas.

Here is my code:

        DOM_Document doc = parser.getDocument();
        DOM_DocumentType docType = doc.getDoctype();
        DOM_NamedNodeMap entities = docType.getEntities();
        char *name = entities.item(0).getNodeName().transcode();
        char *value = entities.item(0).getNodeValue().transcode();
        for (int i = 0; i < entities.getLength(); i++) {
            char *name = entities.item(i).getNodeName().transcode();
            char *value = entities.item(i).getNodeValue().transcode();
            int children = entities.item(i).hasChildNodes();
            cout << "Got Entity name: " << name << "; "
                 << "value: " << value << "; "
                 << "Has subnodes: " << children << endl;
            if (children == 1) {
                DOM_Node child = entities.item(i).getFirstChild();
                name = child.getNodeName().transcode();
                value = child.getNodeValue().transcode();
                children = child.hasChildNodes();
                cout << "\tGot Child name: " << name << "; "
                     << "value: " << value << "; "
                     << "Has subnodes: " << children << endl;
            }
        }

This is the document:
<?xml version="1.0" standalone="yes"?>
<!DOCTYPE foo [
<!ENTITY data    "DATA">
<!ELEMENT  foo        ANY>
]>
<foo>This  &quot; &lt; &gt; is a test &data; of entities</foo>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to