Created
January 28, 2016 13:50
-
-
Save jdkane3/46683446e104ee0feac9 to your computer and use it in GitHub Desktop.
Simple groovy XSLT code
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
import javax.xml.transform.TransformerFactory | |
import javax.xml.transform.stream.StreamResult | |
import javax.xml.transform.stream.StreamSource | |
// Load xslt | |
def xslt= new File("MyTrasform.xsl").getText() | |
// Create transformer | |
def transformer = TransformerFactory.newInstance().newTransformer(new StreamSource(new StringReader(xslt))) | |
// Load xml | |
def xml= new File("MyXml.xml").getText() | |
// Set output file | |
def html = new FileOutputStream("output.html") | |
// Perform transformation | |
transformer.transform(new StreamSource(new StringReader(xml)), new StreamResult(html)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Do you need this line?
def html = new FileOutputStream("output.html")
This works better
transformer.transform(new StreamSource(new StringReader(xml)), new StreamResult("output.html"))