Lines 71-74
Link Here
|
71 |
import org.apache.xalan.xslt.XSLTInputSource; |
71 |
import javax.xml.transform.stream.StreamSource; |
72 |
import org.apache.xalan.xslt.XSLTProcessor; |
72 |
import javax.xml.transform.dom.DOMSource; |
73 |
import org.apache.xalan.xslt.XSLTProcessorFactory; |
73 |
import javax.xml.transform.sax.SAXSource; |
74 |
import org.apache.xalan.xslt.XSLTResultTarget; |
74 |
import javax.xml.transform.Transformer; |
75 |
-- |
75 |
import javax.xml.transform.TransformerFactory; |
|
|
76 |
import javax.xml.transform.Source; |
77 |
import javax.xml.transform.sax.SAXSource; |
78 |
import javax.xml.transform.sax.SAXResult; |
79 |
import javax.xml.transform.dom.DOMSource; |
80 |
import javax.xml.transform.dom.DOMResult; |
81 |
import javax.xml.transform.stream.StreamSource; |
82 |
import javax.xml.transform.stream.StreamResult; |
83 |
|
84 |
import javax.xml.transform.Result; |
85 |
|
Line 76
Link Here
|
|
|
87 |
import org.w3c.dom.Document; |
88 |
import org.w3c.dom.Element; |
89 |
|
Line 78
Link Here
|
|
|
92 |
import org.xml.sax.XMLReader; |
93 |
import org.xml.sax.helpers.XMLReaderFactory; |
Line 223
Link Here
|
223 |
return (EVAL_BODY_TAG); |
239 |
return (EVAL_BODY_INCLUDE); |
224 |
-- |
|
|
Lines 253-266
Link Here
|
253 |
// Prepare an input source for the data |
269 |
Source src = null; |
254 |
XSLTInputSource data = null; |
270 |
Source xslSrc = null; |
255 |
if (body != null) |
271 |
Result result = null; |
256 |
data = new XSLTInputSource(new StringReader(body)); |
272 |
|
257 |
else |
273 |
// Prepare an input source for the data |
258 |
data = getInputSource(nameXml, propertyXml, xml); |
274 |
if (body != null) { |
259 |
|
275 |
src = getSourceFromString(body); |
260 |
// Prepare an input source for the stylesheet |
276 |
} else { |
261 |
XSLTInputSource style = |
277 |
src = getInputSource(nameXml, propertyXml, xml); |
262 |
getInputSource(nameXsl, propertyXsl, xsl); |
278 |
}; |
263 |
|
279 |
xslSrc = getInputSource(nameXsl, propertyXsl, xsl); |
264 |
// Prepare an output source for the results |
280 |
result = new javax.xml.transform.stream.StreamResult( pageContext.getOut() ); |
265 |
XSLTResultTarget result = |
|
|
266 |
new XSLTResultTarget(pageContext.getOut()); |
267 |
-- |
Lines 268-275
Link Here
|
268 |
// Create an XSLT processor and use it to perform the transformation |
282 |
// Create an XSLT transformer and use it to perform the transformation |
269 |
XSLTProcessor processor = null; |
283 |
javax.xml.transform.Transformer transformer = null; |
270 |
try { |
284 |
try { |
271 |
processor = XSLTProcessorFactory.getProcessor(); |
285 |
TransformerFactory factory = TransformerFactory.newInstance(); |
272 |
processor.process(data, style, result); |
286 |
transformer = factory.newTransformer( xslSrc ); |
273 |
} catch (SAXException e) { |
287 |
transformer.transform( src, result ); |
274 |
throw new JspException(e.toString()); |
288 |
} catch (javax.xml.transform.TransformerException e) { |
275 |
} |
289 |
throw new JspException(e); |
276 |
-- |
290 |
}; |
Line 277
Link Here
|
277 |
|
|
|
Line 307
Link Here
|
307 |
private XSLTInputSource getInputSource(String name, String property, |
321 |
private Source getInputSource(String name, String property, |
308 |
-- |
|
|
Line 321
Link Here
|
321 |
return new XSLTInputSource(stream); |
335 |
Source src = getSourceFromStream(stream); |
322 |
-- |
336 |
return src; |
Lines 346-347
Link Here
|
346 |
if (source instanceof XSLTInputSource) |
361 |
if (source instanceof Source ) |
347 |
return ((XSLTInputSource) source); |
362 |
return ( (Source) source ); |
348 |
-- |
|
|
Line 349
Link Here
|
349 |
return (new XSLTInputSource(new StringReader((String) source))); |
364 |
return getSourceFromString( (String)source); |
350 |
-- |
|
|
Line 351
Link Here
|
351 |
return (new XSLTInputSource((InputSource) source)); |
366 |
return ( new SAXSource( (InputSource) source )) ; |
352 |
-- |
|
|
Line 353
Link Here
|
353 |
return (new XSLTInputSource((InputStream) source)); |
368 |
return ( getSourceFromStream( (InputStream) source ) ); |
354 |
-- |
|
|
Lines 355-357
Link Here
|
355 |
return (new XSLTInputSource((Node) source)); |
370 |
return ( getSourceFromDOM( (Node) source ) ); |
356 |
else if (source instanceof Reader) |
371 |
else if (source instanceof Reader) |
357 |
return (new XSLTInputSource((Reader) source)); |
372 |
return ( getSourceFromReader( (Reader) source ) ); |
358 |
-- |
|
|
Line 363
Link Here
|
363 |
|
378 |
|
364 |
-- |
379 |
private Source getSourceFromStream(InputStream stream) { |
|
|
380 |
org.xml.sax.InputSource saxSrc = new org.xml.sax.InputSource(stream); |
381 |
Source src = new SAXSource( saxSrc ); |
382 |
return ( src ); |
383 |
} |
384 |
|
385 |
private Source getSourceFromReader(Reader rdr) { |
386 |
org.xml.sax.InputSource saxSrc = new org.xml.sax.InputSource(rdr); |
387 |
Source src = new SAXSource( saxSrc ); |
388 |
return ( src ); |
389 |
} |
390 |
|
391 |
private Source getSourceFromString(String theString) { |
392 |
org.xml.sax.InputSource saxSrc = new org.xml.sax.InputSource(new StringReader( theString )); |
393 |
Source src = new SAXSource( saxSrc ); |
394 |
return ( src ); |
395 |
} |
396 |
|
397 |
private Source getSourceFromDOM(Node node) { |
398 |
Source answ = null; |
399 |
answ = new javax.xml.transform.dom.DOMSource(node); |
400 |
return answ; |
401 |
} |