return;
}
// 1) Digest the external SCXML file
Digester digester = getDigester();
SCXML scxml = (SCXML) digester.peek(digester.getCount() - 1);
SCXML parent = root;
if (parent == null) {
parent = scxml;
}
String path;
PathResolver nextpr = null;
if (pr == null) {
path = src;
} else {
path = pr.resolvePath(src);
nextpr = pr.getResolver(src);
}
String[] fragments = path.split("#", 2);
String location = fragments[0];
String fragment = null;
if (fragments.length > 1) {
fragment = fragments[1];
}
Digester externalSrcDigester;
if (fragment != null) {
// Cannot pull in all targets just yet, i.e. null parent
externalSrcDigester = newInstance(null, nextpr,
customActions);
} else {
externalSrcDigester = newInstance(parent, nextpr,
customActions);
}
SCXML externalSCXML = null;
try {
externalSCXML = (SCXML) externalSrcDigester.parse(location);
} catch (Exception e) {
org.apache.commons.logging.Log log = LogFactory.
getLog(SCXMLParser.class);
log.error(e.getMessage(), e);
}
// 2) Adopt the children and datamodel
if (externalSCXML == null) {
return;
}
State s = (State) digester.peek();
if (fragment == null) {
// All targets pulled in since its not a src fragment
Initial ini = new Initial();
Transition t = new Transition();
t.setNext(externalSCXML.getInitialstate());
ini.setTransition(t);
s.setInitial(ini);
Map children = externalSCXML.getChildren();
Iterator childIter = children.values().iterator();
while (childIter.hasNext()) {
s.addChild((TransitionTarget) childIter.next());
}
s.setDatamodel(externalSCXML.getDatamodel());
} else {
// Need to pull in descendent targets
Object source = externalSCXML.getTargets().get(fragment);
if (source == null) {
org.apache.commons.logging.Log log = LogFactory.
getLog(SCXMLParser.class);
log.error("Unknown fragment in <state src=\"" + path +
"\">");