string TemplateProcessor::process(Match *m, PElement e, Responder *r, const string &id) { string buffer = ""; if (e == NULL) { return buffer; } try { PElement child = e->getChild(); while (child != NULL) { if (child->getTagname() == "#text") { buffer += child->getText(); } else if (child->getTagname() == "#cdata") { buffer += child->getText(false); } else { // child = checkCompatability(child); /////////////// BEGIN NIGHTMARE ///////////////////////////////// if (child->hasNamespace()) { // Then we need to use the responder if (r == NULL) { // This is temporary!!!!! } else { buffer += r->respond(m, child, id); } } else { /////////////// END NIGHTMARE CODE ////////////////////////////// /* string tagname = child->getTagname(); if (child->hasNamespace()) { tagname = child->getNamespace(); // Temporary hack until responders put in } */ AimlProcessor *p = TemplateProcessor::getProcessor(child->getTagname()); if (p == NULL) { // Then nothing to process this tag with buffer += process(m, child, r, id); // is that right? } else { buffer += p->process(m, child, r, id); } } } child = child->getNextSibling(); } } catch (int &ex) { } return buffer; }
string TemplateProcessor::process(Match *m, PElement e, Responder *r, const string &id) { string buffer = ""; if (e == NULL) { return buffer; } try { PElement child = e->getChild(); while (child != NULL) { if (child->getTagname() == "#text") { buffer += child->getText(); } else if (child->getTagname() == "#cdata") { buffer += child->getText(false); } else { if (child->hasNamespace()) { if (r == NULL) { ; } else { buffer += r->respond(m, child, id); } } else { child = checkCompatibility(child); AimlProcessor *p = TemplateProcessor::getProcessor(child->getTagname()); if (p == NULL) { // Then nothing to process this tag with buffer += process(m, child, r, id); } else { buffer += p->process(m, child, r, id); } } } child = child->getNextSibling(); } } catch (int &ex) { } return buffer; }