blob: 0800c7687bed5d3cb40a0ff32a07f751ba980779 [file] [log] [blame]
{
"classLoaderSharing" : "workflow",
"script" : "//From a proposal by Mikolaj Rybinski\nimport javax.xml.transform.Source;\nimport javax.xml.transform.Transformer;\nimport javax.xml.transform.TransformerFactory;\nimport javax.xml.transform.stream.StreamResult;\nimport javax.xml.transform.stream.StreamSource;\n\nparam(paramstr) {\n nameAndValue = paramstr.split(\"=\");\n if (nameAndValue.length != 2) {\n throw new RuntimeException(\"Wrong parameter format: \\\"\" + paramstr + \"\\\".\");\n }\n name = nameAndValue[0].trim();\n value = nameAndValue[1].trim();\n return this;\n}\n\nif ((sourceString == void) || (sourceString == null)) {\n throw new RuntimeException(\"sourceString must be specified\");\n}\n\nif ((xsltString == void) || (xsltString == null)) {\n throw new RuntimeException(\"xsltString must be specified\");\n}\n\nSource inSource = new StreamSource(new StringReader(sourceString));\nSource xslSource = new StreamSource(new StringReader(xsltString));\n\n// the factory pattern supports different XSLT processors\n// e.g. set the \"javax.xml.transform.TransformerFactory\" system property\nTransformerFactory tnfFact = TransformerFactory.newInstance();\nTransformer tnf = tnfFact.newTransformer(xslSource);\n\nif (paramList != void) {\n for (String paramstr : paramList) {\n p = param(paramstr);\n tnf.setParameter(p.name, p.value);\n }\n}\n\nWriter outputWriter = new StringWriter();\ntnf.transform(inSource, new StreamResult(outputWriter));\noutputString = outputWriter.toString();",
"localworkerName" : "net.sourceforge.taverna.scuflworkers.xml.XSLTWorkerWithParameters",
"inputPorts" : [ {
"name" : "sourceString",
"depth" : 0,
"type" : "String"
}, {
"name" : "xsltString",
"depth" : 0,
"type" : "String"
}, {
"name" : "paramList",
"depth" : 1,
"type" : "String"
} ],
"outputPorts" : [ {
"name" : "outputString",
"depth" : 0,
"granularDepth" : 0
} ],
"isAltered" : false
}