Created
February 1, 2017 15:37
-
-
Save torstenwerner/ccb7f1cfc330195904436d2ff1b90551 to your computer and use it in GitHub Desktop.
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
/** | |
* Xsd 1.1 validation with a pimped xerces2 jar. | |
*/ | |
@Grapes( | |
@Grab(group = 'com.rackspace.apache', module = 'xerces2-xsd11', version = '2.11.2') | |
) | |
import javax.xml.transform.stream.StreamSource | |
import javax.xml.validation.SchemaFactory | |
def schemaName = 'choice-xs11.xsd' | |
def instanceName = 'instance-xs11.xml' | |
def schemaDocument = new StreamSource(new FileInputStream(schemaName)) | |
def instanceDocument = new StreamSource(new FileInputStream(instanceName)) | |
def factory = SchemaFactory.newInstance("http://www.w3.org/XML/XMLSchema/v1.1") | |
def schema = factory.newSchema(schemaDocument) | |
def validator = schema.newValidator() | |
validator.validate(instanceDocument) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment