+ // Possibly transform the input into a different URL to use.
+ if (!m_subst.empty()) {
+ string::size_type pos = m_subst.find("$entityID");
+ if (pos != string::npos) {
+ string name2 = m_subst;
+ name2.replace(pos, 9, m_encoded ? XMLToolingConfig::getConfig().getURLEncoder()->encode(name.c_str()) : name);
+ log.info("transformed location from (%s) to (%s)", name.c_str(), name2.c_str());
+ name = name2;
+ }
+ }
+ else if (!m_match.empty() && !m_regex.empty()) {
+ try {
+ RegularExpression exp(m_match.c_str());
+ XMLCh* temp = exp.replace(name.c_str(), m_regex.c_str());
+ if (temp) {
+ auto_ptr_char narrow(temp);
+ XMLString::release(&temp);
+
+ // For some reason it returns the match string if it doesn't match the expression.
+ if (name != narrow.get()) {
+ log.info("transformed location from (%s) to (%s)", name.c_str(), narrow.get());
+ name = narrow.get();
+ }
+ }
+ }
+ catch (XMLException& ex) {
+ auto_ptr_char msg(ex.getMessage());
+ log.error("caught error applying regular expression: %s", msg.get());
+ }
+ }
+