Skip to content

Commit

Permalink
Java formatted XSLTTransformer.java
Browse files Browse the repository at this point in the history
  • Loading branch information
fzakaria committed Jul 15, 2024
1 parent c2d612d commit e6097f8
Showing 1 changed file with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
import java.io.File;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import java.io.File;

public class XSLTTransformer {
public static void main(String[] args) throws Exception {
if (args.length != 2) {
System.err.println("Usage: java XSLTTransformer <input.xml> <transform.xslt>");
System.exit(1);
}
public static void main(String[] args) throws Exception {
if (args.length != 2) {
System.err.println("Usage: java XSLTTransformer <input.xml> <transform.xslt>");
System.exit(1);
}

String inputXML = args[0];
String xsltFile = args[1];
String inputXML = args[0];
String xsltFile = args[1];

// Create transformer factory
TransformerFactory factory = TransformerFactory.newInstance();
// Create transformer factory
TransformerFactory factory = TransformerFactory.newInstance();

// Load the XSLT file
StreamSource xslt = new StreamSource(new File(xsltFile));
// Load the XSLT file
StreamSource xslt = new StreamSource(new File(xsltFile));

// Create a transformer
Transformer transformer = factory.newTransformer(xslt);
// Create a transformer
Transformer transformer = factory.newTransformer(xslt);

// Load the input XML file
StreamSource xmlInput = new StreamSource(new File(inputXML));
// Load the input XML file
StreamSource xmlInput = new StreamSource(new File(inputXML));

// Set the output file
StreamResult xmlOutput = new StreamResult(System.out);
// Set the output file
StreamResult xmlOutput = new StreamResult(System.out);

// Perform the transformation
transformer.transform(xmlInput, xmlOutput);
}
// Perform the transformation
transformer.transform(xmlInput, xmlOutput);
}
}

0 comments on commit e6097f8

Please sign in to comment.