00001 package net.threebit.utils.sosc;
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 import java.io.*;
00023 import java.sql.*;
00024 import java.util.*;
00025 import javax.xml.transform.stream.*;
00026 import javax.xml.transform.*;
00027
00028
00032 public class XmlTool {
00033
00042
00043
00047 static public void transform (String xml, String xslt, OutputStream destination) throws Exception {
00048 transform (
00049 new StreamSource(new StringReader(xml)),
00050 new StreamSource(new StringReader(xslt)),
00051 destination
00052 );
00053 }
00054
00058 static public void transform (StringBuffer xml, File xslt, OutputStream destination) throws Exception {
00059 transform(
00060 new StreamSource(new StringReader(xml.toString())),
00061 new StreamSource( xslt ),
00062 destination
00063 );
00064 }
00065
00069 static public void transform (StreamSource xmlSource, StreamSource xsltSource, OutputStream destination) throws Exception {
00070 Result result = new StreamResult( destination );
00071 TransformerFactory tf = TransformerFactory.newInstance();
00072 Transformer transformer = tf.newTransformer( xsltSource );
00073 transformer.transform( xmlSource, result );
00074 }
00075 }