summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/uscxml/interpreter/BasicContentExecutor.cpp2
-rw-r--r--src/uscxml/interpreter/InterpreterImpl.cpp23
2 files changed, 24 insertions, 1 deletions
diff --git a/src/uscxml/interpreter/BasicContentExecutor.cpp b/src/uscxml/interpreter/BasicContentExecutor.cpp
index 9796c4c..696b575 100644
--- a/src/uscxml/interpreter/BasicContentExecutor.cpp
+++ b/src/uscxml/interpreter/BasicContentExecutor.cpp
@@ -289,7 +289,7 @@ void BasicContentExecutor::processLog(XERCESC_NS::DOMElement* content) {
}
void BasicContentExecutor::processScript(XERCESC_NS::DOMElement* content) {
- // download as necessary
+ // contents were already downloaded in setupDOM, see to SCXML rec 5.8
std::string scriptContent(X(content->getTextContent()));
_callbacks->eval(scriptContent);
diff --git a/src/uscxml/interpreter/InterpreterImpl.cpp b/src/uscxml/interpreter/InterpreterImpl.cpp
index 60448f9..f7a46fc 100644
--- a/src/uscxml/interpreter/InterpreterImpl.cpp
+++ b/src/uscxml/interpreter/InterpreterImpl.cpp
@@ -295,6 +295,29 @@ SCXML_STOP_SEARCH:
_name = _baseURL.pathComponents().back();
}
+ // download all script, see issue 134
+ std::list<DOMElement*> scripts = DOMUtils::filterChildElements(_xmlPrefix + "script", _scxml, true);
+ for (auto script : scripts) {
+ if (HAS_ATTR(script, kXMLCharSource)) {
+ std::string src = ATTR(script, kXMLCharSource);
+ std::string contents;
+ if (src.size() > 0) {
+ URL url(src);
+ if (!url.isAbsolute()) {
+ url = URL::resolve(url, _baseURL);
+ }
+ contents = url.getInContent();
+ } else {
+ ERROR_COMMUNICATION2(exc, "Empty source attribute", script);
+ throw exc;
+ }
+
+ XERCESC_NS::DOMText* scriptText = _document->createTextNode(X(contents));
+ XERCESC_NS::DOMNode* newNode = _document->importNode(scriptText, true);
+ script->appendChild(newNode);
+ }
+ }
+
_binding = (HAS_ATTR(_scxml, kXMLCharBinding) && iequals(ATTR(_scxml, kXMLCharBinding), "late") ? LATE : EARLY);
}