Use local copy of latest bndlib code for pre-release testing purposes
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1347815 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/bundleplugin/src/main/java/aQute/libg/xslt/Transform.java b/bundleplugin/src/main/java/aQute/libg/xslt/Transform.java
new file mode 100644
index 0000000..ea0fcd0
--- /dev/null
+++ b/bundleplugin/src/main/java/aQute/libg/xslt/Transform.java
@@ -0,0 +1,44 @@
+package aQute.libg.xslt;
+
+import java.io.*;
+import java.net.*;
+import java.util.*;
+import java.util.concurrent.*;
+
+import javax.xml.transform.*;
+import javax.xml.transform.stream.*;
+
+public class Transform {
+ static TransformerFactory transformerFactory = TransformerFactory
+ .newInstance();
+
+ static Map<URL, Templates> cache = new ConcurrentHashMap<URL, Templates>();
+
+ public static void transform(TransformerFactory transformerFactory, URL xslt, InputStream in, OutputStream out)
+ throws Exception {
+ if ( xslt == null )
+ throw new IllegalArgumentException("No source template specified");
+
+ Templates templates = cache.get(xslt);
+ if (templates == null) {
+ InputStream xsltIn = xslt.openStream();
+ try {
+ templates = transformerFactory
+ .newTemplates(new StreamSource(xsltIn));
+
+ cache.put(xslt, templates);
+ } finally {
+ in.close();
+ }
+ }
+ Result xmlResult = new StreamResult(out);
+ Source xmlSource = new StreamSource(in);
+ Transformer t = templates.newTransformer();
+ t.transform(xmlSource, xmlResult);
+ out.flush();
+ }
+
+ public static void transform(URL xslt, InputStream in, OutputStream out) throws Exception {
+ transform(transformerFactory,xslt, in, out);
+ }
+}
diff --git a/bundleplugin/src/main/java/aQute/libg/xslt/packageinfo b/bundleplugin/src/main/java/aQute/libg/xslt/packageinfo
new file mode 100644
index 0000000..7c8de03
--- /dev/null
+++ b/bundleplugin/src/main/java/aQute/libg/xslt/packageinfo
@@ -0,0 +1 @@
+version 1.0