summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/uscxml-transform.cpp4
-rw-r--r--embedding/csharp/uSCXMLEmbedding/RunTests.cs18
-rw-r--r--embedding/java/src/org/uscxml/tests/TestExceptions.java4
-rw-r--r--embedding/java/src/org/uscxml/tests/TestLifecycle.java12
-rw-r--r--embedding/java/src/org/uscxml/tests/TestValidation.java2
-rw-r--r--embedding/java/src/org/uscxml/tests/datamodel/TestDataModelAccess.java4
-rw-r--r--embedding/java/src/org/uscxml/tests/datamodel/TestPlatformExtensions.java2
-rw-r--r--embedding/java/src/org/uscxml/tests/execContent/TestCustomExecContent.java2
-rw-r--r--embedding/java/src/org/uscxml/tests/invoker/adhoc/TestAdhocInvoker.java2
-rw-r--r--embedding/java/src/org/uscxml/tests/invoker/factory/TestCustomInvoker.java2
-rw-r--r--embedding/java/src/org/uscxml/tests/ioprocessor/adhoc/TestAdhocIOProc.java2
-rw-r--r--embedding/java/src/org/uscxml/tests/ioprocessor/adhoc/console/ConsoleFrame.java2
-rw-r--r--embedding/java/src/org/uscxml/tests/ioprocessor/factory/TestCustomIOProc.java2
-rw-r--r--embedding/java/src/org/uscxml/tests/monitor/TestCustomMonitor.java2
-rw-r--r--src/uscxml/Interpreter.cpp50
-rw-r--r--src/uscxml/Interpreter.h9
-rw-r--r--src/uscxml/debug/DebugSession.cpp2
-rw-r--r--src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp4
-rw-r--r--src/uscxml/transform/ChartToPromela.cpp15
-rw-r--r--test/ctest/CTestCustom.ctest.in2
-rw-r--r--test/src/test-datamodel.cpp4
-rw-r--r--test/src/test-issue-reporting.cpp4
-rw-r--r--test/src/test-lifecycle.cpp12
-rw-r--r--test/src/test-predicates.cpp2
-rw-r--r--test/uscxml/xinclude/included.scxml3
-rw-r--r--test/uscxml/xinclude/test-xinclude.scxml9
26 files changed, 109 insertions, 67 deletions
diff --git a/apps/uscxml-transform.cpp b/apps/uscxml-transform.cpp
index 44ca034..62e9278 100644
--- a/apps/uscxml-transform.cpp
+++ b/apps/uscxml-transform.cpp
@@ -174,7 +174,9 @@ int main(int argc, char** argv) {
while (std::getline(std::cin, line)) {
ss << line;
}
- interpreter = Interpreter::fromXML(ss.str());
+ URL tmp("anonymous.scxml");
+ tmp.toAbsoluteCwd();
+ interpreter = Interpreter::fromXML(ss.str(), tmp);
} else {
interpreter = Interpreter::fromURI(inputFile);
}
diff --git a/embedding/csharp/uSCXMLEmbedding/RunTests.cs b/embedding/csharp/uSCXMLEmbedding/RunTests.cs
index d2b188d..5b39c9f 100644
--- a/embedding/csharp/uSCXMLEmbedding/RunTests.cs
+++ b/embedding/csharp/uSCXMLEmbedding/RunTests.cs
@@ -98,7 +98,7 @@ namespace embedding
"</scxml>";
// parse and interpret
- Interpreter interpreter = Interpreter.fromXML(xml);
+ Interpreter interpreter = Interpreter.fromXML(xml, "");
interpreter.interpret();
}
@@ -142,7 +142,7 @@ namespace embedding
"</scxml>";
// parse and interpret
- Interpreter interpreter = Interpreter.fromXML(xml);
+ Interpreter interpreter = Interpreter.fromXML(xml, "");
interpreter.interpret();
}
@@ -167,7 +167,7 @@ namespace embedding
" <transition target=\"exit\" />" +
" </state>\n" +
" <final id=\"exit\" />" +
- "</scxml>\n"
+ "</scxml>\n", ""
);
interpreter.interpret();
interpreter.Dispose();
@@ -180,7 +180,7 @@ namespace embedding
try
{
String xml = "<invalid";
- Interpreter interpreter = Interpreter.fromXML(xml);
+ Interpreter interpreter = Interpreter.fromXML(xml, "");
Debug.Assert(false);
}
catch (InterpreterException e)
@@ -192,7 +192,7 @@ namespace embedding
try
{
String xml = "<invalid />";
- Interpreter interpreter = Interpreter.fromXML(xml);
+ Interpreter interpreter = Interpreter.fromXML(xml, "");
Debug.Assert(interpreter.getState() == InterpreterState.USCXML_INSTANTIATED);
interpreter.step();
Debug.Assert(false);
@@ -212,7 +212,7 @@ namespace embedding
" </state>" +
" <final id=\"done\" />" +
"</scxml>";
- Interpreter interpreter = Interpreter.fromXML(xml);
+ Interpreter interpreter = Interpreter.fromXML(xml, "");
Debug.Assert(interpreter.getState() == InterpreterState.USCXML_INSTANTIATED);
interpreter.step();
Debug.Assert(false);
@@ -237,7 +237,7 @@ namespace embedding
" <final id=\"done\" />" +
"</scxml>";
- Interpreter interpreter = Interpreter.fromXML(xml);
+ Interpreter interpreter = Interpreter.fromXML(xml, "");
Debug.Assert(interpreter.getState() == InterpreterState.USCXML_INSTANTIATED);
Debug.Assert(interpreter.step() == InterpreterState.USCXML_MICROSTEPPED);
@@ -262,7 +262,7 @@ namespace embedding
" <final id=\"done\" />" +
"</scxml>";
- Interpreter interpreter = Interpreter.fromXML(xml);
+ Interpreter interpreter = Interpreter.fromXML(xml, "");
Debug.Assert(interpreter.getState() == InterpreterState.USCXML_INSTANTIATED);
Debug.Assert(interpreter.step() == InterpreterState.USCXML_MICROSTEPPED);
Debug.Assert(interpreter.step() == InterpreterState.USCXML_FINISHED);
@@ -296,7 +296,7 @@ namespace embedding
" <final id=\"done\" />" +
"</scxml>";
- Interpreter interpreter = Interpreter.fromXML(xml);
+ Interpreter interpreter = Interpreter.fromXML(xml, "");
Debug.Assert(interpreter.getState() == InterpreterState.USCXML_INSTANTIATED);
Debug.Assert(interpreter.step() == InterpreterState.USCXML_IDLE);
Debug.Assert(interpreter.step(true) == InterpreterState.USCXML_MACROSTEPPED);
diff --git a/embedding/java/src/org/uscxml/tests/TestExceptions.java b/embedding/java/src/org/uscxml/tests/TestExceptions.java
index 95242b8..b64d9e8 100644
--- a/embedding/java/src/org/uscxml/tests/TestExceptions.java
+++ b/embedding/java/src/org/uscxml/tests/TestExceptions.java
@@ -18,13 +18,13 @@ public class TestExceptions {
if (false) {
// datamodel not available before first step -> dies with segfault
- Interpreter interpreter = Interpreter.fromXML(xml);
+ Interpreter interpreter = Interpreter.fromXML(xml, "");
System.out.println(interpreter.getDataModel().evalAsString("'FOO'"));
}
if (false) {
// datamodel is available but syntactic ecmascript exception is not propagated
- Interpreter interpreter = Interpreter.fromXML(xml);
+ Interpreter interpreter = Interpreter.fromXML(xml, "");
interpreter.step();
System.out.println(interpreter.getDataModel().evalAsString("'FOO' / qwer"));
}
diff --git a/embedding/java/src/org/uscxml/tests/TestLifecycle.java b/embedding/java/src/org/uscxml/tests/TestLifecycle.java
index 9278cbe..7fd168f 100644
--- a/embedding/java/src/org/uscxml/tests/TestLifecycle.java
+++ b/embedding/java/src/org/uscxml/tests/TestLifecycle.java
@@ -11,7 +11,7 @@ public class TestLifecycle {
// syntactic xml parse error -> throws
try {
String xml = "<invalid";
- Interpreter interpreter = Interpreter.fromXML(xml);
+ Interpreter interpreter = Interpreter.fromXML(xml, "");
throw new RuntimeException("");
} catch (InterpreterException e) {
System.err.println(e);
@@ -20,7 +20,7 @@ public class TestLifecycle {
// semantic xml parse error -> throws
try {
String xml = "<invalid />";
- Interpreter interpreter = Interpreter.fromXML(xml);
+ Interpreter interpreter = Interpreter.fromXML(xml, "");
if (interpreter.getState() != InterpreterState.USCXML_INSTANTIATED) throw new RuntimeException("");
interpreter.step();
throw new RuntimeException("");
@@ -37,7 +37,7 @@ public class TestLifecycle {
" </state>" +
" <final id=\"done\" />" +
"</scxml>";
- Interpreter interpreter = Interpreter.fromXML(xml);
+ Interpreter interpreter = Interpreter.fromXML(xml, "");
if (interpreter.getState() != InterpreterState.USCXML_INSTANTIATED) throw new RuntimeException("");
interpreter.step();
throw new RuntimeException("");
@@ -59,7 +59,7 @@ public class TestLifecycle {
" <final id=\"done\" />" +
"</scxml>";
- Interpreter interpreter = Interpreter.fromXML(xml);
+ Interpreter interpreter = Interpreter.fromXML(xml, "");
if (interpreter.getState() != InterpreterState.USCXML_INSTANTIATED) throw new RuntimeException("");
if (interpreter.step() != InterpreterState.USCXML_MICROSTEPPED) throw new RuntimeException("");
@@ -80,7 +80,7 @@ public class TestLifecycle {
" <final id=\"done\" />" +
"</scxml>";
- Interpreter interpreter = Interpreter.fromXML(xml);
+ Interpreter interpreter = Interpreter.fromXML(xml, "");
if (interpreter.getState() != InterpreterState.USCXML_INSTANTIATED) throw new RuntimeException("");
if (interpreter.step() != InterpreterState.USCXML_MICROSTEPPED) throw new RuntimeException("");
if (interpreter.step() != InterpreterState.USCXML_FINISHED) throw new RuntimeException("");
@@ -110,7 +110,7 @@ public class TestLifecycle {
" <final id=\"done\" />" +
"</scxml>";
- Interpreter interpreter = Interpreter.fromXML(xml);
+ Interpreter interpreter = Interpreter.fromXML(xml, "");
if (interpreter.getState() != InterpreterState.USCXML_INSTANTIATED) throw new RuntimeException("");
if (interpreter.step() != InterpreterState.USCXML_IDLE) throw new RuntimeException("");
if (interpreter.step(true) != InterpreterState.USCXML_MACROSTEPPED) throw new RuntimeException("");
diff --git a/embedding/java/src/org/uscxml/tests/TestValidation.java b/embedding/java/src/org/uscxml/tests/TestValidation.java
index 2177214..d42b47d 100644
--- a/embedding/java/src/org/uscxml/tests/TestValidation.java
+++ b/embedding/java/src/org/uscxml/tests/TestValidation.java
@@ -18,7 +18,7 @@ public class TestValidation {
" </state>" +
" <final />" +
"</scxml>";
- Interpreter interpreter = Interpreter.fromXML(xml);
+ Interpreter interpreter = Interpreter.fromXML(xml, "");
IssueList issues = interpreter.validate();
for (int i = 0; i < issues.size(); i++) {
System.out.println(issues.get(i));
diff --git a/embedding/java/src/org/uscxml/tests/datamodel/TestDataModelAccess.java b/embedding/java/src/org/uscxml/tests/datamodel/TestDataModelAccess.java
index 892f56d..656bdbf 100644
--- a/embedding/java/src/org/uscxml/tests/datamodel/TestDataModelAccess.java
+++ b/embedding/java/src/org/uscxml/tests/datamodel/TestDataModelAccess.java
@@ -35,7 +35,7 @@ public class TestDataModelAccess {
" <final id=\"done\" />" +
"</scxml>";
- Interpreter interpreter = Interpreter.fromXML(xml);
+ Interpreter interpreter = Interpreter.fromXML(xml, "");
InterpreterState state;
do {
state = interpreter.step();
@@ -71,7 +71,7 @@ public class TestDataModelAccess {
" <final id=\"done\" />" +
"</scxml>";
- Interpreter interpreter = Interpreter.fromXML(xml);
+ Interpreter interpreter = Interpreter.fromXML(xml, "");
interpreter.setSourceURI(TestDataModelAccess.class.getResource("").toString());
InterpreterState state;
do {
diff --git a/embedding/java/src/org/uscxml/tests/datamodel/TestPlatformExtensions.java b/embedding/java/src/org/uscxml/tests/datamodel/TestPlatformExtensions.java
index 4b2a59e..34569e4 100644
--- a/embedding/java/src/org/uscxml/tests/datamodel/TestPlatformExtensions.java
+++ b/embedding/java/src/org/uscxml/tests/datamodel/TestPlatformExtensions.java
@@ -44,7 +44,7 @@ public class TestPlatformExtensions extends DataModelExtension {
" <final id=\"done\" />" +
"</scxml>";
- Interpreter interpreter = Interpreter.fromXML(xml);
+ Interpreter interpreter = Interpreter.fromXML(xml, "");
interpreter.addDataModelExtension(ext);
InterpreterState state;
diff --git a/embedding/java/src/org/uscxml/tests/execContent/TestCustomExecContent.java b/embedding/java/src/org/uscxml/tests/execContent/TestCustomExecContent.java
index 805e6f7..4b2328a 100644
--- a/embedding/java/src/org/uscxml/tests/execContent/TestCustomExecContent.java
+++ b/embedding/java/src/org/uscxml/tests/execContent/TestCustomExecContent.java
@@ -72,7 +72,7 @@ public class TestCustomExecContent extends ExecutableContent {
" <transition target=\"exit\" />" +
" </state>\n" +
" <final id=\"exit\" />" +
- "</scxml>\n"
+ "</scxml>\n", ""
);
interpreter.interpret();
Thread.sleep(1000);
diff --git a/embedding/java/src/org/uscxml/tests/invoker/adhoc/TestAdhocInvoker.java b/embedding/java/src/org/uscxml/tests/invoker/adhoc/TestAdhocInvoker.java
index b0382fa..3714a53 100644
--- a/embedding/java/src/org/uscxml/tests/invoker/adhoc/TestAdhocInvoker.java
+++ b/embedding/java/src/org/uscxml/tests/invoker/adhoc/TestAdhocInvoker.java
@@ -76,7 +76,7 @@ public class TestAdhocInvoker extends Invoker {
TestAdhocInvoker javainvoker2 = new TestAdhocInvoker();
// parse and interpret
- Interpreter interpreter = Interpreter.fromXML(xml);
+ Interpreter interpreter = Interpreter.fromXML(xml, "");
interpreter.setInvoker("javainvoker1", javainvoker1);
interpreter.setInvoker("javainvoker2", javainvoker2);
interpreter.interpret();
diff --git a/embedding/java/src/org/uscxml/tests/invoker/factory/TestCustomInvoker.java b/embedding/java/src/org/uscxml/tests/invoker/factory/TestCustomInvoker.java
index 637a656..b883125 100644
--- a/embedding/java/src/org/uscxml/tests/invoker/factory/TestCustomInvoker.java
+++ b/embedding/java/src/org/uscxml/tests/invoker/factory/TestCustomInvoker.java
@@ -85,7 +85,7 @@ public class TestCustomInvoker extends Invoker {
"</scxml>";
// parse and interpret
- Interpreter interpreter = Interpreter.fromXML(xml);
+ Interpreter interpreter = Interpreter.fromXML(xml, "");
interpreter.interpret();
}
diff --git a/embedding/java/src/org/uscxml/tests/ioprocessor/adhoc/TestAdhocIOProc.java b/embedding/java/src/org/uscxml/tests/ioprocessor/adhoc/TestAdhocIOProc.java
index fcb9688..f816d0a 100644
--- a/embedding/java/src/org/uscxml/tests/ioprocessor/adhoc/TestAdhocIOProc.java
+++ b/embedding/java/src/org/uscxml/tests/ioprocessor/adhoc/TestAdhocIOProc.java
@@ -134,7 +134,7 @@ public class TestAdhocIOProc extends IOProcessor {
TestAdhocIOProc ioProc = new TestAdhocIOProc();
// parse and interpret
- Interpreter interpreter = Interpreter.fromXML(xml);
+ Interpreter interpreter = Interpreter.fromXML(xml, "");
interpreter.addIOProcessor(ioProc);
interpreter.interpret();
}
diff --git a/embedding/java/src/org/uscxml/tests/ioprocessor/adhoc/console/ConsoleFrame.java b/embedding/java/src/org/uscxml/tests/ioprocessor/adhoc/console/ConsoleFrame.java
index aced20e..332151c 100644
--- a/embedding/java/src/org/uscxml/tests/ioprocessor/adhoc/console/ConsoleFrame.java
+++ b/embedding/java/src/org/uscxml/tests/ioprocessor/adhoc/console/ConsoleFrame.java
@@ -43,7 +43,7 @@ public class ConsoleFrame extends Frame {
+ " </transition>"
+ " </state>"
+ " <final id=\"quit\" />"
- + "</scxml>");
+ + "</scxml>", "");
/**
* ConsoleIOProc will register as a keyboard listener and send events to the interpreter.
diff --git a/embedding/java/src/org/uscxml/tests/ioprocessor/factory/TestCustomIOProc.java b/embedding/java/src/org/uscxml/tests/ioprocessor/factory/TestCustomIOProc.java
index c37cdb4..80e2e13 100644
--- a/embedding/java/src/org/uscxml/tests/ioprocessor/factory/TestCustomIOProc.java
+++ b/embedding/java/src/org/uscxml/tests/ioprocessor/factory/TestCustomIOProc.java
@@ -136,7 +136,7 @@ public class TestCustomIOProc extends IOProcessor {
"</scxml>";
// parse and interpret
- Interpreter interpreter = Interpreter.fromXML(xml);
+ Interpreter interpreter = Interpreter.fromXML(xml, "");
interpreter.interpret();
}
diff --git a/embedding/java/src/org/uscxml/tests/monitor/TestCustomMonitor.java b/embedding/java/src/org/uscxml/tests/monitor/TestCustomMonitor.java
index c748f50..5db4ad4 100644
--- a/embedding/java/src/org/uscxml/tests/monitor/TestCustomMonitor.java
+++ b/embedding/java/src/org/uscxml/tests/monitor/TestCustomMonitor.java
@@ -40,7 +40,7 @@ public class TestCustomMonitor extends InterpreterMonitor {
"</scxml>";
// parse and interpret
- Interpreter interpreter = Interpreter.fromXML(xml);
+ Interpreter interpreter = Interpreter.fromXML(xml, "");
TestCustomMonitor monitor = new TestCustomMonitor();
interpreter.addMonitor(monitor);
diff --git a/src/uscxml/Interpreter.cpp b/src/uscxml/Interpreter.cpp
index 4dabcb9..cb780df 100644
--- a/src/uscxml/Interpreter.cpp
+++ b/src/uscxml/Interpreter.cpp
@@ -372,7 +372,7 @@ InterpreterImpl::InterpreterImpl() {
#endif
}
-Interpreter Interpreter::fromDOM(const Arabica::DOM::Document<std::string>& dom, const NameSpaceInfo& nameSpaceInfo) {
+Interpreter Interpreter::fromDOM(const Arabica::DOM::Document<std::string>& dom, const NameSpaceInfo& nameSpaceInfo, const std::string& sourceURI) {
tthread::lock_guard<tthread::recursive_mutex> lock(_instanceMutex);
boost::shared_ptr<INTERPRETER_IMPL> interpreterImpl = boost::shared_ptr<INTERPRETER_IMPL>(new INTERPRETER_IMPL);
Interpreter interpreter(interpreterImpl);
@@ -397,14 +397,14 @@ Interpreter Interpreter::fromDOM(const Arabica::DOM::Document<std::string>& dom,
return interpreter;
}
-Interpreter Interpreter::fromXML(const std::string& xml) {
+Interpreter Interpreter::fromXML(const std::string& xml, const std::string& sourceURI) {
std::stringstream* ss = new std::stringstream();
(*ss) << xml;
// we need an auto_ptr for arabica to assume ownership
std::auto_ptr<std::istream> ssPtr(ss);
Arabica::SAX::InputSource<std::string> inputSource;
inputSource.setByteStream(ssPtr);
- return fromInputSource(inputSource);
+ return fromInputSource(inputSource, sourceURI);
}
@@ -421,7 +421,7 @@ Interpreter Interpreter::fromURI(const std::string& uri) {
if (iequals(absUrl.scheme(), "file")) {
Arabica::SAX::InputSource<std::string> inputSource;
inputSource.setSystemId(absUrl.asString());
- interpreter = fromInputSource(inputSource);
+ interpreter = fromInputSource(inputSource, absUrl);
} else {
// use curl for everything !file - even for http as arabica won't follow redirects
std::stringstream ss;
@@ -429,20 +429,17 @@ Interpreter Interpreter::fromURI(const std::string& uri) {
if (absUrl.downloadFailed()) {
ERROR_COMMUNICATION_THROW("Downloading SCXML document from '" + absUrl.asString() + "' failed");
}
- interpreter = fromXML(ss.str());
+ interpreter = fromXML(ss.str(), absUrl);
}
// try to establish URI root for relative src attributes in document
- if (interpreter) {
- interpreter._impl->_baseURI = URL::asBaseURL(absUrl);
- interpreter._impl->_sourceURI = absUrl;
- } else {
+ if (!interpreter) {
ERROR_PLATFORM_THROW("Cannot create interpreter from URI '" + absUrl.asString() + "'");
}
return interpreter;
}
-Interpreter Interpreter::fromInputSource(Arabica::SAX::InputSource<std::string>& source) {
+Interpreter Interpreter::fromInputSource(Arabica::SAX::InputSource<std::string>& source, const std::string& sourceUri) {
tthread::lock_guard<tthread::recursive_mutex> lock(_instanceMutex);
// remove old instances
@@ -463,6 +460,9 @@ Interpreter Interpreter::fromInputSource(Arabica::SAX::InputSource<std::string>&
if (parser.parse(source) && parser.getDocument() && parser.getDocument().hasChildNodes()) {
interpreterImpl->setNameSpaceInfo(parser.nameSpace);
interpreterImpl->_document = parser.getDocument();
+ interpreterImpl->_baseURI = URL::asBaseURL(sourceUri);
+ interpreterImpl->_sourceURI = sourceUri;
+
interpreterImpl->setupDOM();
} else {
if (parser.errorsReported()) {
@@ -1224,6 +1224,8 @@ void InterpreterImpl::setupDOM() {
ERROR_PLATFORM_THROW("Interpreter has no DOM");
}
+ resolveXIncludes();
+
// find scxml element
if (!_scxml) {
NodeList<std::string> scxmls;
@@ -1284,6 +1286,34 @@ void InterpreterImpl::setupDOM() {
_domIsSetup = true;
}
+void InterpreterImpl::resolveXIncludes() {
+ std::string xIncludeNS = _nsInfo.getXMLPrefixForNS("http://www.w3.org/2001/XInclude");
+ if (xIncludeNS.size() > 0) {
+ Arabica::XPath::NodeSet<std::string> xincludes = _xpath.evaluate("//" + xIncludeNS + "include", _document.getDocumentElement()).asNodeSet();
+ for (int i = 0; i < xincludes.size(); i++) {
+ if (HAS_ATTR_CAST(xincludes[i], "href")) {
+ URL src(ATTR_CAST(xincludes[i], "href"));
+ if (!src.isAbsolute()) {
+ if (!src.toAbsolute(_baseURI)) {
+ LOG(ERROR) << "Cannot resolve relative URL '" << ATTR_CAST(xincludes[i], "href") << "' to absolute URL via base URL '" << _baseURI << "'";
+ continue;
+ }
+ }
+ NameSpacingParser xiParser = NameSpacingParser::fromXML(src.getInContent());
+ if (xiParser.errorsReported()) {
+ ERROR_PLATFORM_THROW(xiParser.errors());
+ } else {
+ // import DOM
+ Node<std::string> imported = _document.importNode(xiParser.getDocument().getDocumentElement(), true);
+ xincludes[i].getParentNode().insertBefore(imported, xincludes[i]);
+ xincludes[i].getParentNode().removeChild(xincludes[i]);
+ }
+ }
+ }
+ }
+
+}
+
void InterpreterImpl::init() {
// make sure we have a factory if none was set before
if (_factory == NULL)
diff --git a/src/uscxml/Interpreter.h b/src/uscxml/Interpreter.h
index d6da7bd..d962083 100644
--- a/src/uscxml/Interpreter.h
+++ b/src/uscxml/Interpreter.h
@@ -458,6 +458,7 @@ protected:
InterpreterImpl();
void init();
void setupDOM();
+ void resolveXIncludes();
virtual void setupIOProcessors();
std::list<InterpreterIssue> validate();
@@ -583,8 +584,10 @@ protected:
class USCXML_API Interpreter {
public:
static Interpreter fromDOM(const Arabica::DOM::Document<std::string>& dom,
- const NameSpaceInfo& nameSpaceInfo);
- static Interpreter fromXML(const std::string& xml);
+ const NameSpaceInfo& nameSpaceInfo,
+ const std::string& sourceURI);
+ static Interpreter fromXML(const std::string& xml,
+ const std::string& sourceURI);
static Interpreter fromURI(const std::string& uri);
static Interpreter fromClone(const Interpreter& other);
@@ -815,7 +818,7 @@ protected:
return _impl->setInvokeRequest(req);
}
- static Interpreter fromInputSource(Arabica::SAX::InputSource<std::string>& source);
+ static Interpreter fromInputSource(Arabica::SAX::InputSource<std::string>& source, const std::string& sourceUri);
boost::shared_ptr<InterpreterImpl> _impl;
static std::map<std::string, boost::weak_ptr<InterpreterImpl> > _instances;
diff --git a/src/uscxml/debug/DebugSession.cpp b/src/uscxml/debug/DebugSession.cpp
index c73f53e..d81be51 100644
--- a/src/uscxml/debug/DebugSession.cpp
+++ b/src/uscxml/debug/DebugSession.cpp
@@ -106,7 +106,7 @@ Data DebugSession::debugPrepare(const Data& data) {
_isAttached = false;
if (data.hasKey("xml")) {
- _interpreter = Interpreter::fromXML(data.at("xml").atom);
+ _interpreter = Interpreter::fromXML(data.at("xml").atom, "");
} else if (data.hasKey("url")) {
_interpreter = Interpreter::fromURI(data.at("url").atom);
} else {
diff --git a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp
index 5a447c4..84e5520 100644
--- a/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp
+++ b/src/uscxml/plugins/invoker/scxml/USCXMLInvoker.cpp
@@ -82,9 +82,9 @@ void USCXMLInvoker::invoke(const InvokeRequest& req) {
Arabica::DOM::Node<std::string> newNode = dom.importNode(req.dom, true);
dom.appendChild(newNode);
// TODO: where do we get the namespace from?
- _invokedInterpreter = Interpreter::fromDOM(dom, std::map<std::string, std::string>());
+ _invokedInterpreter = Interpreter::fromDOM(dom, _interpreter->getNameSpaceInfo(), _interpreter->getSourceURI());
} else if (req.content.size() > 0) {
- _invokedInterpreter = Interpreter::fromXML(req.content);
+ _invokedInterpreter = Interpreter::fromXML(req.content, _interpreter->getSourceURI());
} else {
LOG(ERROR) << "Cannot invoke nested SCXML interpreter, neither src attribute nor content nor DOM is given";
}
diff --git a/src/uscxml/transform/ChartToPromela.cpp b/src/uscxml/transform/ChartToPromela.cpp
index 9d297ad..7676a37 100644
--- a/src/uscxml/transform/ChartToPromela.cpp
+++ b/src/uscxml/transform/ChartToPromela.cpp
@@ -2041,6 +2041,7 @@ void ChartToPromela::writeDeclarations(std::ostream& stream) {
if (_analyzer->getTypes().types.find("_ioprocessors") != _analyzer->getTypes().types.end()) {
stream << "hidden _ioprocessors_t " << _prefix << "_ioprocessors;" << std::endl;
+ _varInitializers.push_front("_ioprocessors.scxml.location = " + (_invokerid.size() > 0 ? _analyzer->macroForLiteral(_invokerid) : "1") + ";");
}
if (_prefix.size() == 0 || _prefix == "MAIN_") {
@@ -2110,21 +2111,17 @@ void ChartToPromela::writeDeclarations(std::ostream& stream) {
type = type.substr(0, bracketPos);
}
std::string decl = type + " " + _prefix + identifier + arrSize;
+ stream << decl << ";" << std::endl;
if (arrSize.length() > 0) {
- stream << decl << ";" << std::endl;
_varInitializers.push_back(value);
} else {
- stream << decl;
if (expression.length() > 0) {
// id and expr given
- stream << " = " << ADAPT_SRC(boost::trim_copy(expression)) << ";" << std::endl;
+ _varInitializers.push_back(identifier + " = " + boost::trim_copy(expression) + ";");
} else if (value.length() > 0) {
// id and text content given
- stream << " = " << ADAPT_SRC(value) << ";" << std::endl;
- } else {
- // only id given
- stream << ";" << std::endl;
+ _varInitializers.push_back(identifier + " = " + value + ";");
}
}
} else if (value.length() > 0) {
@@ -2625,7 +2622,7 @@ void ChartToPromela::writeMain(std::ostream& stream) {
if (_varInitializers.size() > 0) {
std::list<std::string>::iterator initIter = _varInitializers.begin();
while(initIter != _varInitializers.end()) {
- stream << ADAPT_SRC(beautifyIndentation(*initIter));
+ stream << ADAPT_SRC(beautifyIndentation(*initIter)) << std::endl;
initIter++;
}
stream << std::endl;
@@ -2717,7 +2714,7 @@ void ChartToPromela::initNodes() {
Node<std::string> importRoot = nestedDoc.importNode(nestedRoot[0], true);
nestedDoc.appendChild(importRoot);
- nested = Interpreter::fromDOM(nestedDoc, _nsInfo);
+ nested = Interpreter::fromDOM(nestedDoc, _nsInfo, _sourceURI);
}
// std::cout << invokes[i] << std::endl;
diff --git a/test/ctest/CTestCustom.ctest.in b/test/ctest/CTestCustom.ctest.in
index 1362ea5..feba4c1 100644
--- a/test/ctest/CTestCustom.ctest.in
+++ b/test/ctest/CTestCustom.ctest.in
@@ -104,7 +104,6 @@ set(CTEST_CUSTOM_TESTS_IGNORE
"spin/promela/test178.scxml" # manual test with two identical params - failed
"spin/promela/test194.scxml" # illegal target for send
"spin/promela/test199.scxml" # invalid send type
- "spin/promela/test215.scxml" # nested SCXML document with typeexpr at invoke
"spin/promela/test216.scxml" # nested SCXML document with srcexpr at invoke
"spin/promela/test230.scxml" # nested SCXML document with manual test
"spin/promela/test298.scxml" # non-existent data model location
@@ -113,7 +112,6 @@ set(CTEST_CUSTOM_TESTS_IGNORE
"spin/promela/test343.scxml" # test that illegal <param> produces error.execution
"spin/promela/test488.scxml" # illegal expr in <param> produces error.execution
"spin/promela/test496.scxml" # tests error.communication with illegal target
- "spin/promela/test500.scxml" # uses _ioprocessors.scxml.location
"spin/promela/test513.txt" # pure manual wget
"spin/promela/test521.scxml" # tests error.communication with illegal target
"spin/promela/test528.scxml" # illegal 'expr' produces error.execution
diff --git a/test/src/test-datamodel.cpp b/test/src/test-datamodel.cpp
index f0b7536..4b93b4d 100644
--- a/test/src/test-datamodel.cpp
+++ b/test/src/test-datamodel.cpp
@@ -52,7 +52,7 @@ int main(int argc, char** argv) {
}
- Interpreter interpreter = Interpreter::fromXML("<scxml></scxml>");
+ Interpreter interpreter = Interpreter::fromXML("<scxml></scxml>", "");
DataModel dm(Factory::getInstance()->createDataModel("ecmascript", interpreter.getImpl().get()));
dm.evalAsString("var foo = 12");
@@ -513,7 +513,7 @@ int main(int argc, char** argv) {
"</scxml>";
TestDataModelExtension ext;
- Interpreter interpreter = Interpreter::fromXML(xml);
+ Interpreter interpreter = Interpreter::fromXML(xml, "");
interpreter.addDataModelExtension(&ext);
InterpreterState state;
diff --git a/test/src/test-issue-reporting.cpp b/test/src/test-issue-reporting.cpp
index 39dad05..98c2a21 100644
--- a/test/src/test-issue-reporting.cpp
+++ b/test/src/test-issue-reporting.cpp
@@ -5,7 +5,7 @@
using namespace uscxml;
std::set<std::string> issueLocationsForXML(const std::string xml) {
- Interpreter interpreter = Interpreter::fromXML(xml);
+ Interpreter interpreter = Interpreter::fromXML(xml, "");
std::list<InterpreterIssue> issues = interpreter.validate();
std::set<std::string> issueLocations;
@@ -52,7 +52,7 @@ int main(int argc, char** argv) {
"</scxml>";
IssueMonitor monitor;
- Interpreter interpreter = Interpreter::fromXML(xml);
+ Interpreter interpreter = Interpreter::fromXML(xml, "");
interpreter.addMonitor(&monitor);
interpreter.interpret();
diff --git a/test/src/test-lifecycle.cpp b/test/src/test-lifecycle.cpp
index 8ecad37..ff2fafd 100644
--- a/test/src/test-lifecycle.cpp
+++ b/test/src/test-lifecycle.cpp
@@ -217,7 +217,7 @@ int main(int argc, char** argv) {
// syntactic xml parse error
try {
const char* xml = "<invalid";
- Interpreter interpreter = Interpreter::fromXML(xml);
+ Interpreter interpreter = Interpreter::fromXML(xml, "");
assert(false);
} catch (Event& e) {
std::cout << e;
@@ -228,7 +228,7 @@ int main(int argc, char** argv) {
// semantic xml parse error
try {
const char* xml = "<invalid />";
- Interpreter interpreter = Interpreter::fromXML(xml);
+ Interpreter interpreter = Interpreter::fromXML(xml, "");
interpreter.addMonitor(mon);
assert(interpreter.getState() == USCXML_INSTANTIATED);
interpreter.step();
@@ -248,7 +248,7 @@ int main(int argc, char** argv) {
" </state>"
" <final id=\"done\" />"
"</scxml>";
- Interpreter interpreter = Interpreter::fromXML(xml);
+ Interpreter interpreter = Interpreter::fromXML(xml, "");
interpreter.addMonitor(mon);
assert(interpreter.getState() == USCXML_INSTANTIATED);
interpreter.step();
@@ -271,7 +271,7 @@ int main(int argc, char** argv) {
" <final id=\"done\" />"
"</scxml>";
- Interpreter interpreter = Interpreter::fromXML(xml);
+ Interpreter interpreter = Interpreter::fromXML(xml, "");
interpreter.addMonitor(mon);
callBackSeq.push_back(USCXML_BEFOREENTERINGSTATE);
@@ -315,7 +315,7 @@ int main(int argc, char** argv) {
" <final id=\"done\" />"
"</scxml>";
- Interpreter interpreter = Interpreter::fromXML(xml);
+ Interpreter interpreter = Interpreter::fromXML(xml, "");
interpreter.addMonitor(mon);
callBackSeq.push_back(USCXML_BEFOREENTERINGSTATE);
@@ -374,7 +374,7 @@ int main(int argc, char** argv) {
" <final id=\"done\" />"
"</scxml>";
- Interpreter interpreter = Interpreter::fromXML(xml);
+ Interpreter interpreter = Interpreter::fromXML(xml, "");
interpreter.addMonitor(mon);
callBackSeq.push_back(USCXML_BEFOREENTERINGSTATE);
diff --git a/test/src/test-predicates.cpp b/test/src/test-predicates.cpp
index 02e0faf..f66e8ba 100644
--- a/test/src/test-predicates.cpp
+++ b/test/src/test-predicates.cpp
@@ -20,7 +20,7 @@ int main(int argc, char** argv) {
" </parallel>"
"</scxml>";
- Interpreter interpreter = Interpreter::fromXML(xml);
+ Interpreter interpreter = Interpreter::fromXML(xml, "");
assert(interpreter);
interpreter.getImpl()->init();
diff --git a/test/uscxml/xinclude/included.scxml b/test/uscxml/xinclude/included.scxml
new file mode 100644
index 0000000..4d8c8f5
--- /dev/null
+++ b/test/uscxml/xinclude/included.scxml
@@ -0,0 +1,3 @@
+<state id="start">
+ <transition target="pass" />
+</state> \ No newline at end of file
diff --git a/test/uscxml/xinclude/test-xinclude.scxml b/test/uscxml/xinclude/test-xinclude.scxml
new file mode 100644
index 0000000..a07c087
--- /dev/null
+++ b/test/uscxml/xinclude/test-xinclude.scxml
@@ -0,0 +1,9 @@
+<scxml xmlns:xi="http://www.w3.org/2001/XInclude">
+ <xi:include href="included.scxml" />
+ <final id="fail">
+ <onentry><log expr="FAIL!" /></onentry>
+ </final>
+ <final id="pass">
+ <onentry><log expr="PASS!" /></onentry>
+ </final>
+</scxml> \ No newline at end of file