forked from patniemeyer/learningjava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathXSLTransform.java
More file actions
24 lines (20 loc) · 751 Bytes
/
Copy pathXSLTransform.java
File metadata and controls
24 lines (20 loc) · 751 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
public class XSLTransform
{
public static void main( String [] args ) throws Exception
{
if ( args.length < 2 || !args[0].endsWith(".xsl") ) {
System.err.println("usage: XSLTransform file.xsl file.xml");
System.exit(1);
}
String xslFile = args[0], xmlFile = args[1];
//String xslFile = "zooinventory.xsl", xmlFile = "zooinventory.xml";
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer =
factory.newTransformer( new StreamSource( xslFile ) );
StreamSource xmlsource = new StreamSource( xmlFile );
StreamResult output = new StreamResult( System.out );
transformer.transform( xmlsource, output );
}
}