+ // Now try regexs.
+ for (vector< pair< bool, pair<string,string> > >::const_iterator r = m_regex.begin(); r != m_regex.end(); ++r) {
+ try {
+ RegularExpression exp(r->second.first.c_str());
+ XMLCh* temp = exp.replace(entityID.c_str(), r->second.second.c_str());
+ if (temp) {
+ auto_ptr_char narrow(temp);
+ XMLString::release(&temp);
+
+ if (r->first) {
+ m_log.info("forcibly transformed entityID from (%s) to (%s)", entityID.c_str(), narrow.get());
+ entityID = narrow.get();
+ }
+
+ m_log.debug("attempting lookup with entityID (%s)", narrow.get());
+
+ mc.entityID_ascii = narrow.get();
+ entity = m->getEntityDescriptor(mc);
+ if (entity.first) {
+ m_log.info("transformed entityID from (%s) to (%s)", entityID.c_str(), narrow.get());
+ if (!r->first)
+ entityID = narrow.get();
+ return;
+ }
+ }
+ }
+ catch (XMLException& ex) {
+ auto_ptr_char msg(ex.getMessage());
+ m_log.error("caught error applying regular expression: %s", msg.get());
+ }
+ }
+