X-Git-Url: http://wamblee.org/gitweb/?a=blobdiff_plain;f=support%2Fgeneral%2Fsrc%2Fmain%2Fjava%2Forg%2Fwamblee%2Fxml%2FXslTransformer.java;h=003cb8bb2054a9d958f1c47d9d251c91da96a59b;hb=8de36ff0206c996baf3ee4adc3e2293b12ff5f39;hp=640aece320e28e3b9a9bc853dd0399cf186854a3;hpb=89c06d4d52b46c154128c97d6e758fa1f4fc7a6e;p=utils diff --git a/support/general/src/main/java/org/wamblee/xml/XslTransformer.java b/support/general/src/main/java/org/wamblee/xml/XslTransformer.java index 640aece3..003cb8bb 100644 --- a/support/general/src/main/java/org/wamblee/xml/XslTransformer.java +++ b/support/general/src/main/java/org/wamblee/xml/XslTransformer.java @@ -36,21 +36,17 @@ import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamSource; - /** * XSL transformer for simplified usage of XSL transformations. - * + * * @author Erik Brakkee */ public class XslTransformer { - /** - * DOCUMENT ME! - */ private TransformerFactory factory; -/** + /** * Constructs the URL resolver. - * + * * @param aResolver * URI resolver to use. */ @@ -59,9 +55,9 @@ public class XslTransformer { factory.setURIResolver(aResolver); } -/** + /** * Constructs the XSLT processor. - * + * */ public XslTransformer() { factory = TransformerFactory.newInstance(); @@ -69,12 +65,14 @@ public class XslTransformer { /** * Resolves an XSLT based on URI. - * - * @param aXslt XSLT to resolve, - * + * + * @param aXslt + * XSLT to resolve, + * * @return Source for the XSLT - * - * @throws TransformerException In case the XSLT cannot be found. + * + * @throws TransformerException + * In case the XSLT cannot be found. */ public Source resolve(String aXslt) throws TransformerException { URIResolver resolver = factory.getURIResolver(); @@ -96,20 +94,24 @@ public class XslTransformer { } /** - * Transforms a DOM document into another DOM document using a - * given XSLT transformation. - * - * @param aDocument Document to transform. - * @param aXslt XSLT to use. - * + * Transforms a DOM document into another DOM document using a given XSLT + * transformation. + * + * @param aDocument + * Document to transform. + * @param aXslt + * XSLT to use. + * * @return Transformed document. - * - * @throws IOException In case of problems reading resources. - * @throws TransformerException In case transformation fails. + * + * @throws IOException + * In case of problems reading resources. + * @throws TransformerException + * In case transformation fails. */ public Document transform(Document aDocument, Source aXslt) throws IOException, TransformerException { - Source source = new DOMSource(aDocument); + Source source = new DOMSource(aDocument); DOMResult result = new DOMResult(); transform(source, result, aXslt); @@ -118,18 +120,22 @@ public class XslTransformer { /** * Transforms a document using XSLT. - * - * @param aDocument Document to transform. - * @param aXslt XSLT to use. - * + * + * @param aDocument + * Document to transform. + * @param aXslt + * XSLT to use. + * * @return Transformed document. - * - * @throws IOException In case of problems reading resources. - * @throws TransformerException In case transformation fails. + * + * @throws IOException + * In case of problems reading resources. + * @throws TransformerException + * In case transformation fails. */ public Document transform(byte[] aDocument, Source aXslt) throws IOException, TransformerException { - Source source = new StreamSource(new ByteArrayInputStream(aDocument)); + Source source = new StreamSource(new ByteArrayInputStream(aDocument)); DOMResult result = new DOMResult(); transform(source, result, aXslt); @@ -139,21 +145,20 @@ public class XslTransformer { /** * Transforms a document to a text output. This supports XSLT * transformations that result in text documents. - * - * @param aDocument Document to transform. - * @param aXslt XSL transformation. - * + * + * @param aDocument + * Document to transform. + * @param aXslt + * XSL transformation. + * * @return Transformed document. - * - * @throws IOException DOCUMENT ME! - * @throws TransformerException DOCUMENT ME! + * */ public String textTransform(byte[] aDocument, Source aXslt) throws IOException, TransformerException { - Source source = new StreamSource(new ByteArrayInputStream( - aDocument)); - ByteArrayOutputStream os = new ByteArrayOutputStream(); - StreamResult result = new StreamResult(os); + Source source = new StreamSource(new ByteArrayInputStream(aDocument)); + ByteArrayOutputStream os = new ByteArrayOutputStream(); + StreamResult result = new StreamResult(os); transform(source, result, aXslt); return new String(os.toByteArray()); @@ -161,13 +166,18 @@ public class XslTransformer { /** * Transforms a document using XSLT. - * - * @param aSource Document to transform. - * @param aResult Result of the transformation. - * @param aXslt XSLT to use. - * - * @throws IOException In case of problems reading resources. - * @throws TransformerException In case transformation fails. + * + * @param aSource + * Document to transform. + * @param aResult + * Result of the transformation. + * @param aXslt + * XSLT to use. + * + * @throws IOException + * In case of problems reading resources. + * @throws TransformerException + * In case transformation fails. */ public void transform(Source aSource, Result aResult, Source aXslt) throws IOException, TransformerException { @@ -175,8 +185,8 @@ public class XslTransformer { Transformer transformer = factory.newTransformer(aXslt); transformer.transform(aSource, aResult); } catch (TransformerConfigurationException e) { - throw new TransformerException("Configuration problem of XSLT transformation", - e); + throw new TransformerException( + "Configuration problem of XSLT transformation", e); } } }