Skip to content

Instantly share code, notes, and snippets.

@torstenwerner
Created February 1, 2017 16:44
Show Gist options
  • Save torstenwerner/e0a170e41027f12fca18b1c78d6441e7 to your computer and use it in GitHub Desktop.
Save torstenwerner/e0a170e41027f12fca18b1c78d6441e7 to your computer and use it in GitHub Desktop.
/**
* Simple schematron executer for a schema which is embedded into a Xml schema.
*/
import javax.xml.transform.TransformerFactory
import javax.xml.transform.stream.StreamResult
import javax.xml.transform.stream.StreamSource
def schemaName = 'choice-schematron.xsd'
def instanceName = 'instance-schematron.xml'
def reportName = 'instance.svrlt'
factory = TransformerFactory.newInstance()
transform('ExtractSchFromXSD.xsl', schemaName, 'choice.sch')
transform('iso_svrl_for_xslt1.xsl', 'choice.sch', 'choice-schematron.xsl')
transform('choice-schematron.xsl', instanceName, reportName)
def transform(xsltName, inputName, outputName) {
def xslt = new StreamSource(new File(xsltName))
def transformer = factory.newTransformer(xslt)
def input = new StreamSource(new File(inputName))
def output = new StreamResult(new File(outputName))
transformer.transform(input, output)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment