summaryrefslogtreecommitdiffstats
path: root/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-04-12 11:57:08 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2013-04-12 11:57:08 (GMT)
commitba050afaaad699e60ca657b311d5c34d038bb89c (patch)
treed4c79e30631c63e8557c6ec893a70dda46aa6cd5 /src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp
parent45ab2909e17f7e0348ccfe4179f23a897a2fd305 (diff)
downloaduscxml-ba050afaaad699e60ca657b311d5c34d038bb89c.zip
uscxml-ba050afaaad699e60ca657b311d5c34d038bb89c.tar.gz
uscxml-ba050afaaad699e60ca657b311d5c34d038bb89c.tar.bz2
Refactoring for other datamodels
Diffstat (limited to 'src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp')
-rw-r--r--src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp443
1 files changed, 268 insertions, 175 deletions
diff --git a/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp b/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp
index f874c86..eef8e51 100644
--- a/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp
+++ b/src/uscxml/plugins/datamodel/xpath/XPathDataModel.cpp
@@ -27,7 +27,7 @@ XPathDataModel::XPathDataModel() {
boost::shared_ptr<DataModelImpl> XPathDataModel::create(InterpreterImpl* interpreter) {
boost::shared_ptr<XPathDataModel> dm = boost::shared_ptr<XPathDataModel>(new XPathDataModel());
dm->_interpreter = interpreter;
-// dm->_xpath.setVariableResolver(_varResolver);
+
// dm->_xpath->setVariableCompileTimeResolver(_varCTResolver);
// dm->_xpath->setNamespaceContext(interpreter->getNSContext());
@@ -39,21 +39,21 @@ boost::shared_ptr<DataModelImpl> XPathDataModel::create(InterpreterImpl* interpr
dm->_doc = dm->_domFactory.createDocument("http://www.w3.org/2005/07/scxml", "", 0);
dm->_datamodel = dm->_doc.createElement("datamodel");
dm->_doc.appendChild(dm->_datamodel);
-
+
Element<std::string> ioProcElem = dm->_doc.createElement("data");
ioProcElem.setAttribute("id", "_ioprocessors");
std::map<std::string, IOProcessor>::const_iterator ioProcIter = interpreter->getIOProcessors().begin();
while(ioProcIter != interpreter->getIOProcessors().end()) {
Element<std::string> ioProc = dm->_doc.createElement("processor");
ioProc.setAttribute("name", ioProcIter->first);
-
+
Data ioProcData = ioProcIter->second.getDataModelVariables();
Element<std::string> ioProcLoc = dm->_doc.createElement("location");
Text<std::string> ioProcLocText = dm->_doc.createTextNode(ioProcData.compound["location"].atom);
ioProcLoc.appendChild(ioProcLocText);
ioProc.appendChild(ioProcLoc);
ioProcElem.appendChild(ioProc);
-
+
ioProcIter++;
}
dm->_datamodel.appendChild(ioProcElem);
@@ -61,8 +61,7 @@ boost::shared_ptr<DataModelImpl> XPathDataModel::create(InterpreterImpl* interpr
NodeSet<std::string> ioProcNodeSet;
ioProcNodeSet.push_back(ioProcElem);
dm->_varResolver.setVariable("_ioprocessors", ioProcNodeSet);
-
-
+
Element<std::string> sessIdElem = dm->_doc.createElement("data");
sessIdElem.setAttribute("id", "_sessionid");
Text<std::string> sessIdText = dm->_doc.createTextNode(interpreter->getSessionId());
@@ -73,13 +72,13 @@ boost::shared_ptr<DataModelImpl> XPathDataModel::create(InterpreterImpl* interpr
sessIdNodeSet.push_back(sessIdElem);
dm->_varResolver.setVariable("_sessionid", sessIdNodeSet);
-
+
Element<std::string> nameElem = dm->_doc.createElement("data");
nameElem.setAttribute("id", "_name");
Text<std::string> nameText = dm->_doc.createTextNode(interpreter->getName());
nameElem.appendChild(nameText);
dm->_datamodel.appendChild(nameElem);
-
+
NodeSet<std::string> nameNodeSet;
nameNodeSet.push_back(nameElem);
dm->_varResolver.setVariable("_name", nameNodeSet);
@@ -104,7 +103,7 @@ void XPathDataModel::setEvent(const Event& event) {
eventElem.setAttribute("id", "_event");
Element<std::string> eventDataElem = _doc.createElement("data");
-
+
NodeSet<std::string> eventNodeSet;
if (event.params.size() > 0) {
std::multimap<std::string, std::string>::const_iterator paramIter = event.params.begin();
@@ -131,14 +130,17 @@ void XPathDataModel::setEvent(const Event& event) {
}
}
if (event.content.size() > 0) {
- eventDataElem.setNodeValue(event.content);
+ Text<std::string> textNode = _doc.createTextNode(Interpreter::spaceNormalize(event.content).c_str());
+ eventDataElem.appendChild(textNode);
+ }
+ if (event.dom) {
+ Node<std::string> importedNode = _doc.importNode(event.dom.getFirstChild(), true);
+ eventDataElem.appendChild(importedNode);
}
-
+
eventElem.appendChild(eventDataElem);
eventNodeSet.push_back(eventElem);
-
-// std::cout << eventElem << std::endl;
-
+
// do we need to replace an existing event?
Node<std::string> oldEventElem = _datamodel.getFirstChild();
while(oldEventElem) {
@@ -148,7 +150,7 @@ void XPathDataModel::setEvent(const Event& event) {
}
oldEventElem = oldEventElem.getNextSibling();
}
-
+
if (oldEventElem) {
_datamodel.replaceChild(eventElem, oldEventElem);
} else {
@@ -167,7 +169,7 @@ bool XPathDataModel::validate(const std::string& location, const std::string& sc
}
uint32_t XPathDataModel::getLength(const std::string& expr) {
- return 0;
+ return 0;
}
void XPathDataModel::eval(const std::string& expr) {
@@ -193,9 +195,87 @@ double XPathDataModel::evalAsNumber(const std::string& expr) {
return result.asNumber();
}
+void XPathDataModel::assign(const Arabica::DOM::Element<std::string>& assignElem,
+ const Arabica::DOM::Document<std::string>& doc,
+ const std::string& content) {
+ std::string location;
+ if (HAS_ATTR(assignElem, "id")) {
+ location = ATTR(assignElem, "id");
+ } else if (HAS_ATTR(assignElem, "location")) {
+ location = ATTR(assignElem, "location");
+ }
+
+ XPathValue<std::string> key = _xpath.evaluate_expr(location, _doc);
+ NodeSet<std::string> nodeSet;
+ if (doc) {
+ nodeSet.push_back(doc.getDocumentElement());
+ assign(key, nodeSet, assignElem);
+ } else if (content.length() > 0) {
+ Text<std::string> textNode = _doc.createTextNode(Interpreter::spaceNormalize(content));
+ nodeSet.push_back(textNode);
+ assign(key, nodeSet, assignElem);
+ } else if (HAS_ATTR(assignElem, "expr")) {
+ XPathValue<std::string> value = _xpath.evaluate_expr(ATTR(assignElem, "expr"), _doc);
+ assign(key, value, assignElem);
+ } else {
+ LOG(ERROR) << "assign element has no content";
+ }
+
+ std::cout << _datamodel << std::endl;
+}
+
+void XPathDataModel::assign(const std::string& location, const Data& data) {
+
+}
+
+void XPathDataModel::init(const Arabica::DOM::Element<std::string>& dataElem,
+ const Arabica::DOM::Document<std::string>& doc,
+ const std::string& content) {
+ std::string location;
+ if (HAS_ATTR(dataElem, "id")) {
+ location = ATTR(dataElem, "id");
+ } else if (HAS_ATTR(dataElem, "location")) {
+ location = ATTR(dataElem, "location");
+ }
+
+ Element<std::string> container = _doc.createElement("data");
+ container.setAttribute("id", location);
+ if (doc) {
+ Element<std::string> data = doc.getDocumentElement();
+ if (data.hasChildNodes()) {
+ Node<std::string> dataClone = _doc.importNode(data, true);
+ container.appendChild(dataClone);
+ }
+ } else if (content.length() > 0) {
+ Text<std::string> textNode = _doc.createTextNode(Interpreter::spaceNormalize(content));
+ container.appendChild(textNode);
+ } else if (HAS_ATTR(dataElem, "expr")) {
+ XPathValue<std::string> expr = _xpath.evaluate_expr(ATTR(dataElem, "expr"), _doc);
+ XPathValue<std::string> key = _xpath.evaluate_expr(location, _doc);
+ assign(key, expr, dataElem);
+ for (int i = 0; expr.asNodeSet().size(); i++)
+ container.appendChild(expr.asNodeSet()[i]);
+ } else {
+ LOG(ERROR) << "data element has no content";
+ }
+ _datamodel.appendChild(container);
+
+ // put data element into nodeset and bind to xpath variable
+ NodeSet<std::string> nodeSet;
+ nodeSet.push_back(container);
+ _varResolver.setVariable(location, nodeSet);
+
+ std::cout << _datamodel << std::endl;
+}
+
+void XPathDataModel::init(const std::string& location, const Data& data) {
+
+}
+
+#if 0
void XPathDataModel::assign(const std::string& location,
- const Document<std::string>& doc,
- const Arabica::DOM::Element<std::string>& dataElem) {
+ const Document<std::string>& doc,
+ const Arabica::DOM::Element<std::string>& dataElem) {
XPathValue<std::string> key = _xpath.evaluate_expr(location, _doc);
NodeSet<std::string> nodeSet;
nodeSet.push_back(doc.getDocumentElement());
@@ -203,15 +283,15 @@ void XPathDataModel::assign(const std::string& location,
}
void XPathDataModel::assign(const std::string& location,
- const Data& data,
- const Arabica::DOM::Element<std::string>& dataElem) {
+ const Data& data,
+ const Arabica::DOM::Element<std::string>& dataElem) {
// assert(false);
// std::cout << location << " = " << data << std::endl;
}
void XPathDataModel::assign(const std::string& location,
- const std::string& expr,
- const Arabica::DOM::Element<std::string>& dataElem) {
+ const std::string& expr,
+ const Arabica::DOM::Element<std::string>& dataElem) {
std::string realExpr = (HAS_ATTR(dataElem, "expr") ? ATTR(dataElem, "expr") : expr);
XPathValue<std::string> key = _xpath.evaluate_expr(location, _doc);
XPathValue<std::string> value = _xpath.evaluate_expr(realExpr, _doc);
@@ -219,8 +299,8 @@ void XPathDataModel::assign(const std::string& location,
}
void XPathDataModel::init(const std::string& location,
- const Document<std::string>& doc,
- const Arabica::DOM::Element<std::string>& dataElem) {
+ const Document<std::string>& doc,
+ const Arabica::DOM::Element<std::string>& dataElem) {
Element<std::string> container = _doc.createElement("data");
container.setAttribute("id", location);
Element<std::string> data = doc.getDocumentElement();
@@ -229,7 +309,7 @@ void XPathDataModel::init(const std::string& location,
container.appendChild(dataClone);
}
_datamodel.appendChild(container);
-
+
// put data element into nodeset and bind to xpath variable
NodeSet<std::string> nodeSet;
nodeSet.push_back(container);
@@ -237,11 +317,11 @@ void XPathDataModel::init(const std::string& location,
}
void XPathDataModel::init(const std::string& location,
- const std::string& expr,
- const Arabica::DOM::Element<std::string>& dataElem) {
+ const std::string& expr,
+ const Arabica::DOM::Element<std::string>& dataElem) {
Element<std::string> data = _doc.createElement("data");
data.setAttribute("id", location);
-
+
if (expr.length() > 0) {
Text<std::string> textNode = _doc.createTextNode(expr.c_str());
data.appendChild(textNode);
@@ -255,182 +335,195 @@ void XPathDataModel::init(const std::string& location,
}
void XPathDataModel::init(const std::string& location,
- const Data& data,
- const Arabica::DOM::Element<std::string>& dataElem) {
- assert(false);
+ const Data& data,
+ const Arabica::DOM::Element<std::string>& dataElem) {
+// XPathValue<std::string> key = _xpath.evaluate_expr(location, _doc);
+ init(location, data.atom, dataElem);
}
+#endif
void XPathDataModel::assign(XPathValue<std::string>& key,
- const XPathValue<std::string>& value,
- const Arabica::DOM::Element<std::string>& assignElem) {
+ const XPathValue<std::string>& value,
+ const Arabica::DOM::Element<std::string>& assignElem) {
switch (value.type()) {
- case STRING:
- assign(key, value.asString(), assignElem);
- break;
- case BOOL:
- assign(key, value.asBool(), assignElem);
- break;
- case NUMBER:
- assign(key, value.asNumber(), assignElem);
- break;
- case NODE_SET:
- assign(key, value.asNodeSet(), assignElem);
- break;
- case ANY:
- throw Event("error.execution", Event::PLATFORM);
+ case STRING:
+ assign(key, value.asString(), assignElem);
+ break;
+ case BOOL:
+ assign(key, value.asBool(), assignElem);
+ break;
+ case NUMBER:
+ assign(key, value.asNumber(), assignElem);
+ break;
+ case NODE_SET:
+ assign(key, value.asNodeSet(), assignElem);
+ break;
+ case ANY:
+ throw Event("error.execution", Event::PLATFORM);
}
}
void XPathDataModel::assign(XPathValue<std::string>& key,
- const std::string& value,
- const Arabica::DOM::Element<std::string>& assignElem) {
+ const std::string& value,
+ const Arabica::DOM::Element<std::string>& assignElem) {
switch (key.type()) {
- case NODE_SET: {
- if (key.asNodeSet().size() == 0)
- return;
- Node<std::string> node = key.asNodeSet()[0];
+ case NODE_SET: {
+ if (key.asNodeSet().size() == 0)
+ return;
+ for (int i = 0; i < key.asNodeSet().size(); i++) {
+ Node<std::string> node = key.asNodeSet()[i];
switch (node.getNodeType()) {
- case Node_base::ATTRIBUTE_NODE: {
- Attr<std::string> attr(node);
- attr.setValue(value);
- break;
- }
- case Node_base::TEXT_NODE: {
- Text<std::string> text(node);
- text.setNodeValue(value);
- break;
- }
- case Node_base::ELEMENT_NODE: {
- Element<std::string> element(node);
- if (HAS_ATTR(assignElem, "type") && boost::iequals(ATTR(assignElem, "type"), "addattribute")) {
- // addattribute: Add an attribute with the name specified by 'attr'
- // and value specified by 'expr' to the node specified by 'location'.
- if (!HAS_ATTR(assignElem, "attr"))
- throw Event("error.execution", Event::PLATFORM);
- element.setAttribute(ATTR(assignElem, "attr"), value);
- }
- break;
+ case Node_base::ATTRIBUTE_NODE: {
+ Attr<std::string> attr(node);
+ attr.setValue(value);
+ break;
+ }
+ case Node_base::TEXT_NODE: {
+ Text<std::string> text(node);
+ text.setNodeValue(value);
+ break;
+ }
+ case Node_base::ELEMENT_NODE: {
+ Element<std::string> element(node);
+ if (HAS_ATTR(assignElem, "type") && boost::iequals(ATTR(assignElem, "type"), "addattribute")) {
+ // addattribute: Add an attribute with the name specified by 'attr'
+ // and value specified by 'expr' to the node specified by 'location'.
+ if (!HAS_ATTR(assignElem, "attr"))
+ throw Event("error.execution", Event::PLATFORM);
+ element.setAttribute(ATTR(assignElem, "attr"), value);
+ } else {
+ /// test 547
+ while(element.hasChildNodes())
+ element.removeChild(element.getChildNodes().item(0));
+ Text<std::string> text = _doc.createTextNode(value);
+ element.appendChild(text);
}
- default:
- throw Event("error.execution", Event::PLATFORM);
- break;
+ break;
+ }
+ default:
+ throw Event("error.execution", Event::PLATFORM);
+ break;
}
- break;
}
- case STRING:
- case BOOL:
- case NUMBER:
- case ANY:
- throw Event("error.execution", Event::PLATFORM);
- break;
- default:
- break;
+ break;
+ }
+ case STRING:
+ case BOOL:
+ case NUMBER:
+ case ANY:
+ throw Event("error.execution", Event::PLATFORM);
+ break;
+ default:
+ break;
}
}
void XPathDataModel::assign(XPathValue<std::string>& key,
- const double value,
- const Arabica::DOM::Element<std::string>& assignElem) {
+ const double value,
+ const Arabica::DOM::Element<std::string>& assignElem) {
+ assign(key, toStr(value), assignElem);
}
void XPathDataModel::assign(XPathValue<std::string>& key,
- const bool value,
- const Arabica::DOM::Element<std::string>& assignElem) {
+ const bool value,
+ const Arabica::DOM::Element<std::string>& assignElem) {
}
void XPathDataModel::assign(XPathValue<std::string>& key,
- const NodeSet<std::string>& value,
- const Arabica::DOM::Element<std::string>& assignElem) {
+ const NodeSet<std::string>& value,
+ const Arabica::DOM::Element<std::string>& assignElem) {
switch (key.type()) {
- case NODE_SET: {
- if (key.asNodeSet().size() == 0)
- return;
- Node<std::string> node = key.asNodeSet()[0];
+ case NODE_SET: {
+ if (key.asNodeSet().size() == 0)
+ return;
+ for (int i = 0; i < key.asNodeSet().size(); i++) {
+ Node<std::string> node = key.asNodeSet()[i];
switch (node.getNodeType()) {
- case Node_base::ELEMENT_NODE: {
- Element<std::string> element(node);
- if (false) {
- } else if (HAS_ATTR(assignElem, "type") && boost::iequals(ATTR(assignElem, "type"), "firstchild")) {
- // firstchild: Insert the value specified by 'expr' before all of the children at 'location'.
- for (int i = value.size(); i; i--) {
- Node<std::string> importedNode = _doc.importNode(value[i-1], true);
- element.insertBefore(importedNode, element.getFirstChild());
- }
- } else if (HAS_ATTR(assignElem, "type") && boost::iequals(ATTR(assignElem, "type"), "lastchild")) {
- // lastchild: Insert the value specified by 'expr' after all of the children at 'location'.
- for (int i = 0; i < value.size(); i++) {
- Node<std::string> importedNode = _doc.importNode(value[i], true);
- element.appendChild(importedNode);
- }
- } else if (HAS_ATTR(assignElem, "type") && boost::iequals(ATTR(assignElem, "type"), "previoussibling")) {
- // previoussibling: Insert the value specified by 'expr' before the
- // node specified by 'location', keeping the same parent.
- Node<std::string> parent = element.getParentNode();
- if (!parent)
- throw Event("error.execution", Event::PLATFORM);
- for (int i = 0; i < value.size(); i++) {
- Node<std::string> importedNode = _doc.importNode(value[i], true);
- parent.insertBefore(importedNode, element);
- }
- } else if (HAS_ATTR(assignElem, "type") && boost::iequals(ATTR(assignElem, "type"), "nextsibling")) {
- // nextsibling: Insert the value specified by 'expr' after the node
- // specified by 'location', keeping the same parent.
- Node<std::string> parent = element.getParentNode();
- if (!parent)
- throw Event("error.execution", Event::PLATFORM);
- for (int i = value.size(); i; i--) {
- Node<std::string> importedNode = _doc.importNode(value[i-1], true);
- Node<std::string> nextSibling = element.getNextSibling();
- if (nextSibling) {
- parent.insertBefore(importedNode, element.getNextSibling());
- } else {
- parent.appendChild(importedNode);
- }
- }
- } else if (HAS_ATTR(assignElem, "type") && boost::iequals(ATTR(assignElem, "type"), "replace")) {
- // replace: Replace the node specified by 'location' by the value specified by 'expr'.
- Node<std::string> parent = element.getParentNode();
- if (!parent)
- throw Event("error.execution", Event::PLATFORM);
- if (value.size() != 1)
- throw Event("error.execution", Event::PLATFORM);
- Node<std::string> importedNode = _doc.importNode(value[0], true);
- parent.replaceChild(importedNode, element);
- } else if (HAS_ATTR(assignElem, "type") && boost::iequals(ATTR(assignElem, "type"), "delete")) {
- // delete: Delete the node specified by 'location'. ('expr' is ignored.).
- Node<std::string> parent = element.getParentNode();
- if (!parent)
- throw Event("error.execution", Event::PLATFORM);
- parent.removeChild(element);
- } else {
- // replacechildren: Replace all the children at 'location' with the value specified by 'expr'.
- while(element.hasChildNodes())
- element.removeChild(element.getChildNodes().item(0));
- for (int i = 0; i < value.size(); i++) {
- Node<std::string> importedNode = _doc.importNode(value[i], true);
- element.appendChild(importedNode);
+ case Node_base::ELEMENT_NODE: {
+ Element<std::string> element(node);
+ if (false) {
+ } else if (HAS_ATTR(assignElem, "type") && boost::iequals(ATTR(assignElem, "type"), "firstchild")) {
+ // firstchild: Insert the value specified by 'expr' before all of the children at 'location'.
+ for (int i = value.size(); i; i--) {
+ Node<std::string> importedNode = _doc.importNode(value[i-1], true);
+ element.insertBefore(importedNode, element.getFirstChild());
+ }
+ } else if (HAS_ATTR(assignElem, "type") && boost::iequals(ATTR(assignElem, "type"), "lastchild")) {
+ // lastchild: Insert the value specified by 'expr' after all of the children at 'location'.
+ for (int i = 0; i < value.size(); i++) {
+ Node<std::string> importedNode = _doc.importNode(value[i], true);
+ element.appendChild(importedNode);
+ }
+ } else if (HAS_ATTR(assignElem, "type") && boost::iequals(ATTR(assignElem, "type"), "previoussibling")) {
+ // previoussibling: Insert the value specified by 'expr' before the
+ // node specified by 'location', keeping the same parent.
+ Node<std::string> parent = element.getParentNode();
+ if (!parent)
+ throw Event("error.execution", Event::PLATFORM);
+ for (int i = 0; i < value.size(); i++) {
+ Node<std::string> importedNode = _doc.importNode(value[i], true);
+ parent.insertBefore(importedNode, element);
+ }
+ } else if (HAS_ATTR(assignElem, "type") && boost::iequals(ATTR(assignElem, "type"), "nextsibling")) {
+ // nextsibling: Insert the value specified by 'expr' after the node
+ // specified by 'location', keeping the same parent.
+ Node<std::string> parent = element.getParentNode();
+ if (!parent)
+ throw Event("error.execution", Event::PLATFORM);
+ for (int i = value.size(); i; i--) {
+ Node<std::string> importedNode = _doc.importNode(value[i-1], true);
+ Node<std::string> nextSibling = element.getNextSibling();
+ if (nextSibling) {
+ parent.insertBefore(importedNode, element.getNextSibling());
+ } else {
+ parent.appendChild(importedNode);
}
}
- break;
+ } else if (HAS_ATTR(assignElem, "type") && boost::iequals(ATTR(assignElem, "type"), "replace")) {
+ // replace: Replace the node specified by 'location' by the value specified by 'expr'.
+ Node<std::string> parent = element.getParentNode();
+ if (!parent)
+ throw Event("error.execution", Event::PLATFORM);
+ if (value.size() != 1)
+ throw Event("error.execution", Event::PLATFORM);
+ Node<std::string> importedNode = _doc.importNode(value[0], true);
+ parent.replaceChild(importedNode, element);
+ } else if (HAS_ATTR(assignElem, "type") && boost::iequals(ATTR(assignElem, "type"), "delete")) {
+ // delete: Delete the node specified by 'location'. ('expr' is ignored.).
+ Node<std::string> parent = element.getParentNode();
+ if (!parent)
+ throw Event("error.execution", Event::PLATFORM);
+ parent.removeChild(element);
+ } else {
+ // replacechildren: Replace all the children at 'location' with the value specified by 'expr'.
+ while(element.hasChildNodes())
+ element.removeChild(element.getChildNodes().item(0));
+ for (int i = 0; i < value.size(); i++) {
+ Node<std::string> importedNode = _doc.importNode(value[i], true);
+ element.appendChild(importedNode);
+ }
}
- default:
- throw Event("error.execution", Event::PLATFORM);
- break;
+ break;
+ }
+ default:
+ throw Event("error.execution", Event::PLATFORM);
+ break;
}
- break;
}
- case STRING:
- case BOOL:
- case NUMBER:
- case ANY:
- throw Event("error.execution", Event::PLATFORM);
- break;
+ break;
+ }
+ case STRING:
+ case BOOL:
+ case NUMBER:
+ case ANY:
+ throw Event("error.execution", Event::PLATFORM);
+ break;
}
}
XPathValue<std::string>
- NodeSetVariableResolver::resolveVariable(const std::string& namepaceUri,
- const std::string& name) const {
+NodeSetVariableResolver::resolveVariable(const std::string& namepaceUri,
+ const std::string& name) const {
std::map<std::string, NodeSet<std::string> >::const_iterator n = _variables.find(name);
if(n == _variables.end()) {
throw Event("error.execution");
@@ -439,15 +532,15 @@ XPathValue<std::string>
}
XPathFunction<std::string>*
- XPathFunctionResolver::resolveFunction(const std::string& namespace_uri,
- const std::string& name,
- const std::vector<XPathExpression<std::string> >& argExprs) const {
+XPathFunctionResolver::resolveFunction(const std::string& namespace_uri,
+ const std::string& name,
+ const std::vector<XPathExpression<std::string> >& argExprs) const {
if (boost::iequals(name, "in")) {
return new XPathFunctionIn(1, -1, argExprs, _interpreter);
}
return _xpathFuncRes.resolveFunction(namespace_uri, name, argExprs);
}
-
+
std::vector<std::pair<std::string, std::string> > XPathFunctionResolver::validNames() const {
std::vector<std::pair<std::string, std::string> > names = _xpathFuncRes.validNames();
names.push_back(std::make_pair("", "In"));
@@ -455,7 +548,7 @@ std::vector<std::pair<std::string, std::string> > XPathFunctionResolver::validNa
}
bool XPathFunctionIn::doEvaluate(const Node<std::string>& context,
- const ExecutionContext<std::string>& executionContext) const {
+ const ExecutionContext<std::string>& executionContext) const {
for (int i = 0; i < argCount(); i++) {
XPathValue<std::string> stateName = arg(i, context, executionContext);
if (stateName.type() == STRING) {