while (labels.hasNext()) {
String name = (String) labels.next();
Token token = parameters.get(name);
if (token instanceof StringToken) {
StringToken s = (StringToken) token;
_transformer.setParameter(name, s.stringValue());
} else {
_transformer.setParameter(name, token.toString());
}
}
}
for (int i = 0; i < input.getWidth(); i++) {
if (input.hasToken(i)) {
XMLToken in = (XMLToken) input.get(i);
Document doc = in.getDomTree();
try {
javax.xml.transform.Source xmlSource = new javax.xml.transform.dom.DOMSource(
doc);
_transformer.transform(xmlSource, result);
if (_debugging) {
_debug("--- transform the xmlSource: "
+ in.toString() + "\n");
}
if (out != null) {
if (_debugging) {
_debug("--- moml change request string: "
+ out.toString() + "\n");
}
StringToken outputToken = new StringToken(out
.toString());
output.broadcast(outputToken);
if (_debugging) {
_debug("--- change request string token "
+ "send out. \n");
}
}
} catch (TransformerException ex) {
throw new IllegalActionException(this, ex,
"Failed to process '" + in + "'");
}
try {
out.flush();
out.close();
} catch (IOException ex) {
throw new IllegalActionException(this, ex,
"Failed to close or flush '" + out + "'");
}
}
}
} else {
// If there is no transformer, then output the xml string.
for (int i = 0; i < input.getWidth(); i++) {
if (input.hasToken(i)) {
XMLToken in = (XMLToken) input.get(i);
output.broadcast(new StringToken(in.toString()));
}
}
}
}