def xsd = ''' <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:element name="comics"> </xs:element> </xs:schema> ''' def xml = ''' <comics> </comics> ''' import javax.xml.XMLConstants import javax.xml.transform.stream.StreamSource import javax.xml.validation.SchemaFactory def factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI) def schema = factory.newSchema(new StreamSource(new StringReader(xsd))) def validator = schema.newValidator() validator.validate(new StreamSource(new StringReader(xml)))
Never been to CodeSnippets before?
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)
Groovy XML Schema Validator (See related posts)
You need to create an account or log in to post comments to this site.
Related Posts
» Groovy XML Schema Validator in xml groovy
» XSLT and XHTML DTD's in xhtml XSL xml dtd
» Increase the number of simul... in firefox ajax xml xhr xmlhttprequest
» Somewhat ridiculous XML pars... in php image xml irc
» Example using xmlplarser's s... in ruby rails xml files parse huge saxdriver xmlplarser
» String Samples in groovy
Snippets (source code soon to be available) developed by Peter Cooper and powered by Ruby On Rails