Mercurial > hg > mpdl-group
comparison software/mpdl-services/mpiwg-mpdl-xml/src/de/mpg/mpiwg/berlin/mpdl/xml/transform/BasicTransformer.java @ 23:e845310098ba
diverse Korrekturen
author | Josef Willenborg <jwillenborg@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 27 Nov 2012 12:35:19 +0100 |
parents | dc5e9fcb3fdc |
children |
comparison
equal
deleted
inserted
replaced
22:6a45a982c333 | 23:e845310098ba |
---|---|
86 try { | 86 try { |
87 StreamSource xslStreamSource = new StreamSource(xslUrl); | 87 StreamSource xslStreamSource = new StreamSource(xslUrl); |
88 XsltExecutable xsltExecutable = xsltCompiler.compile(xslStreamSource); | 88 XsltExecutable xsltExecutable = xsltCompiler.compile(xslStreamSource); |
89 xsltTransformer = xsltExecutable.load(); | 89 xsltTransformer = xsltExecutable.load(); |
90 StreamSource xmlDoc = new StreamSource(srcUrl); | 90 StreamSource xmlDoc = new StreamSource(srcUrl); |
91 Serializer serializer = new Serializer(); | |
92 StringWriter stringWriter = new StringWriter(); | |
93 serializer.setOutputWriter(stringWriter); | |
94 setOutputProperties(serializer, outputPropertiesStr); | |
95 xsltTransformer.setSource(xmlDoc); // needs some time for bigger documents | |
96 xsltTransformer.setDestination(serializer); | |
97 setParameters(xsltTransformer, parametersStr); | |
98 xsltTransformer.transform(); // needs some time for bigger documents | |
99 StringWriter out = (StringWriter) serializer.getOutputDestination(); | |
100 retStr = out.toString(); | |
101 } catch (SaxonApiException e) { | |
102 throw new ApplicationException(e); | |
103 } | |
104 return retStr; | |
105 } | |
106 | |
107 public String transform(StringReader inputStrReader, String xslUrl, String parametersStr, String outputPropertiesStr) throws ApplicationException { | |
108 String retStr = null; | |
109 try { | |
110 StreamSource xslStreamSource = new StreamSource(xslUrl); | |
111 XsltExecutable xsltExecutable = xsltCompiler.compile(xslStreamSource); | |
112 xsltTransformer = xsltExecutable.load(); | |
113 StreamSource xmlDoc = new StreamSource(inputStrReader); | |
91 Serializer serializer = new Serializer(); | 114 Serializer serializer = new Serializer(); |
92 StringWriter stringWriter = new StringWriter(); | 115 StringWriter stringWriter = new StringWriter(); |
93 serializer.setOutputWriter(stringWriter); | 116 serializer.setOutputWriter(stringWriter); |
94 setOutputProperties(serializer, outputPropertiesStr); | 117 setOutputProperties(serializer, outputPropertiesStr); |
95 xsltTransformer.setSource(xmlDoc); // needs some time for bigger documents | 118 xsltTransformer.setSource(xmlDoc); // needs some time for bigger documents |
226 xsltTransformer.setParameter(ms2PositionQName, ms2PositionXdmValue); | 249 xsltTransformer.setParameter(ms2PositionQName, ms2PositionXdmValue); |
227 xsltTransformer.transform(); // needs some time for bigger documents | 250 xsltTransformer.transform(); // needs some time for bigger documents |
228 // String pageFragment = serializer.getOutputDestination().toString(); | 251 // String pageFragment = serializer.getOutputDestination().toString(); |
229 // System.out.println(pageFragment); | 252 // System.out.println(pageFragment); |
230 } catch (SaxonApiException e) { | 253 } catch (SaxonApiException e) { |
231 throw new ApplicationException(e); | 254 throw new ApplicationException(e); |
232 } | 255 } |
233 } | 256 } |
234 | 257 |
235 private String transformByTransformerFactory(String xmlString, String xslFileName, String parametersStr, String outputPropertiesStr) throws ApplicationException { | 258 private String transformByTransformerFactory(String xmlString, String xslFileName, String parametersStr, String outputPropertiesStr) throws ApplicationException { |
236 String resultString = null; | 259 String resultString = null; |