String src = attributes.getValue("src");
if (SCXMLHelper.isStringEmpty(src)) {
return;
}
Digester digester = getDigester();
SCXML scxml = (SCXML) digester.peek(digester.getCount() - 1);
// 1) Digest the external SCXML file
SCXML externalSCXML = null;
String path;
Digester externalSrcDigester;
if (pr == null) {
path = src;
externalSrcDigester = newInstance(scxml, null, customActions);
} else {
path = pr.resolvePath(src);
externalSrcDigester = newInstance(scxml, pr.getResolver(src),
customActions);
}
try {
externalSCXML = (SCXML) externalSrcDigester.parse(path);
} catch (Exception e) {
org.apache.commons.logging.Log log = LogFactory.
getLog(SCXMLDigester.class);
log.error(e.getMessage(), e);
}
// 2) Adopt the children and datamodel
if (externalSCXML == null) {
return;
}
State s = (State) digester.peek();
Transition t = new Transition();
t.setNext(externalSCXML.getInitialstate());
Initial ini = new Initial();
ini.setTransition(t);
s.setInitial(ini);
Map children = externalSCXML.getStates();
Object[] ids = children.keySet().toArray();
for (int i = 0; i < ids.length; i++) {
s.addChild((State) children.get(ids[i]));
}
s.setDatamodel(externalSCXML.getDatamodel());
}