-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
21 additions
and
21 deletions.
There are no files selected for viewing
42 changes: 21 additions & 21 deletions
42
java/src/com/github/bazel_contrib/contrib_rules_jvm/xml/XSLTTransformer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |