blob: 6503e112a2d27ed1707377458819be87833a9fb1 [file] [log] [blame]
{
"http://purl.org/dc/terms/rights": "Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the 'License'); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.",
"http://purl.org/dc/terms/license": {"@id": "http://www.apache.org/licenses/LICENSE-2.0"},
"classLoaderSharing" : "workflow",
"script" : "import java.io.BufferedReader;\nimport java.io.BufferedWriter;\nimport java.io.FileInputStream;\nimport java.io.FileNotFoundException;\nimport java.io.FileReader;\nimport java.io.FileWriter;\nimport java.io.IOException;\nimport java.io.InputStreamReader;\nimport java.io.OutputStreamWriter;\nimport java.io.StringWriter;\nimport java.io.Writer;\nimport java.net.URL;\nimport java.util.HashMap;\nimport java.util.Map;\n\nimport javax.xml.transform.Result;\nimport javax.xml.transform.Source;\nimport javax.xml.transform.SourceLocator;\nimport javax.xml.transform.Templates;\nimport javax.xml.transform.Transformer;\nimport javax.xml.transform.TransformerConfigurationException;\nimport javax.xml.transform.TransformerException;\nimport javax.xml.transform.TransformerFactory;\nimport javax.xml.transform.stream.StreamResult;\nimport javax.xml.transform.stream.StreamSource;\n\nBufferedReader getReader (String fileUrl) throws IOException {\n\t\tInputStreamReader reader;\n\t\ttry {\n\t\t\treader = new FileReader(fileUrl);\n\t\t}\n\t\tcatch (FileNotFoundException e) {\n\t\t\t// try a real URL instead\n\t\t\tURL url = new URL(fileUrl);\n\t\t\treader = new InputStreamReader (url.openStream());\n\t\t}\n\t\treturn new BufferedReader(reader);\n\t}\n\t\nBufferedWriter getWriter (String fileUrl) throws IOException {\n\t\tWriter writer;\n\t\ttry {\n\t\t\twriter = new FileWriter(fileUrl);\n\t\t}\n\t\tcatch (FileNotFoundException e) {\n\t\t\t// try a real URL instead\n\t\t\tURL url = new URL(fileUrl);\n\t\t\twriter = new OutputStreamWriter (url.openConnection().getOutputStream());\n\t\t}\n\t\treturn new BufferedWriter(writer);\n\t}\n\t\nString xslFilename = xslFileURL;\nString outFilename;\nif (outFileURL != void) {\n outFilename = outFileURL;\n}\n\nString ext;\nif (outputExt != void) {\n ext = outputExt;\n}\n\nif (((outFilename == null) || outFilename.equals(\"\")) && (ext != null)) {\n\t\toutFilename = inFileURL.substring(0, inFileURL.indexOf(\".\")+1) + ext;\n}\n\n// Create transformer factory\nTransformerFactory factory = TransformerFactory.newInstance();\n\n// Use the factory to create a template containing the xsl file\nTemplates template = factory.newTemplates(new StreamSource(getReader(xslFilename)));\n\n// Use the template to create a transformer\nTransformer xformer = template.newTransformer();\n\n// Prepare the input and output files\nReader sourceReader = getReader(inFileURL);\nSource source = new StreamSource(sourceReader);\nStringWriter resultStr = new StringWriter();\nResult result = new StreamResult(resultStr);\n\n// Apply the xsl file to the source file and write the result to the\n// output file\nxformer.transform(source, result);\n\noutputStr = resultStr.toString();\n\nif ((outFilename != null) && !outFilename.equals(\"\")) {\n\n\tBufferedWriter out = getWriter(outFilename);\n\n\tout.write(outputStr);\n\tout.close();\n}\nsourceReader.close();\n",
"localworkerName" : "net.sourceforge.taverna.scuflworkers.xml.XSLTWorker",
"inputPorts" : [ {
"name" : "xslFileURL",
"depth" : 0,
"type" : "String"
}, {
"name" : "outFileURL",
"depth" : 0,
"type" : "String"
}, {
"name" : "inFileURL",
"depth" : 0,
"type" : "String"
}, {
"name" : "outputExt",
"depth" : 0,
"type" : "String"
} ],
"outputPorts" : [ {
"name" : "outputStr",
"depth" : 0,
"granularDepth" : 0
} ],
"isAltered" : false
}