/* phonebook.xml
Joe Wang
joe@yourserver.com
202-999-9999
www.rntsoft.com
Karol
karol@yourserver.com
306-999-9999
www.rntsoft.com
Green
green@yourserver.com
202-414-9999
www.rntsoft.com
Directory
Name
Telephone
Email
*/
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
public class XMLTransform {
public static void main(String args[]) {
if (args.length != 2) {
System.err.println("Usage: java XMLTransform xmlfile.xml stylesheet.xsl");
System.exit(-1);
}
try {
StreamSource source = new StreamSource(args[0]);
StreamSource stylesource = new StreamSource(args[1]);
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer(stylesource);
StreamResult result = new StreamResult(System.out);
transformer.transform(source, result);
} catch (Exception e) {
e.printStackTrace();
}
}
}