summaryrefslogtreecommitdiff
path: root/utils/src/main/java/at
diff options
context:
space:
mode:
Diffstat (limited to 'utils/src/main/java/at')
-rw-r--r--utils/src/main/java/at/gv/egiz/idlink/IdentityLinkTransformer.java58
1 files changed, 30 insertions, 28 deletions
diff --git a/utils/src/main/java/at/gv/egiz/idlink/IdentityLinkTransformer.java b/utils/src/main/java/at/gv/egiz/idlink/IdentityLinkTransformer.java
index 7886b07d..060ccef5 100644
--- a/utils/src/main/java/at/gv/egiz/idlink/IdentityLinkTransformer.java
+++ b/utils/src/main/java/at/gv/egiz/idlink/IdentityLinkTransformer.java
@@ -16,29 +16,30 @@
*/
package at.gv.egiz.idlink;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import javax.xml.transform.Result;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.stream.StreamSource;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Templates;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.sax.SAXTransformerFactory;
+import javax.xml.transform.stream.StreamSource;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
public class IdentityLinkTransformer {
@@ -77,7 +78,7 @@ public class IdentityLinkTransformer {
/**
* The stylesheet transformer.
*/
- private Transformer transformer;
+ private Templates templates;
/**
* Stylesheet URL.
@@ -103,7 +104,7 @@ public class IdentityLinkTransformer {
}
StreamSource source = new StreamSource(url.openStream());
- transformer = factory.newTransformer(source);
+ templates = factory.newTemplates(source);
initTime = System.currentTimeMillis() - created;
@@ -111,7 +112,8 @@ public class IdentityLinkTransformer {
public void transform(Source xmlSource, Result outputTarget) throws TransformerException {
long t0 = System.currentTimeMillis();
- try {
+ try {
+ Transformer transformer = templates.newTransformer();
transformer.transform(xmlSource, outputTarget);
} catch (TransformerException e) {
throw e;
@@ -146,7 +148,7 @@ public class IdentityLinkTransformer {
/**
* The transfomer factory.
*/
- private static TransformerFactory factory;
+ private static SAXTransformerFactory factory;
/**
* The instance to be returned by {@link #getInstance()}.
@@ -161,7 +163,7 @@ public class IdentityLinkTransformer {
public static IdentityLinkTransformer getInstance() {
if (instance == null) {
instance = new IdentityLinkTransformer();
- factory = TransformerFactory.newInstance();
+ factory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
}
return instance;
}