summaryrefslogtreecommitdiff
path: root/utils/src/main/java/at/gv
diff options
context:
space:
mode:
authormcentner <mcentner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2008-09-24 14:04:18 +0000
committermcentner <mcentner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4>2008-09-24 14:04:18 +0000
commit81eb1e485a03a6bd1efb726892631ab037d59fdb (patch)
tree488e62adb23c3232188a9dab427c2a011e3a3929 /utils/src/main/java/at/gv
parent3edfbe631f24d73324bc4dd0d182ca7737c4d5b5 (diff)
downloadmocca-81eb1e485a03a6bd1efb726892631ab037d59fdb.tar.gz
mocca-81eb1e485a03a6bd1efb726892631ab037d59fdb.tar.bz2
mocca-81eb1e485a03a6bd1efb726892631ab037d59fdb.zip
Modified IdentityLinkTransformer to use cached Templates instead of cached Transformers.
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@67 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'utils/src/main/java/at/gv')
-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;
}