Opotoc Posted June 8, 2012 Posted June 8, 2012 Hi all, inspired by the XML transform found here I created a script to validate a XML against a XSD. Enjoy. Best, Alexander RegisterGroovy( "XMLXSDValidation( xmlString ; xsdString )" ; "import javax.xml.XMLConstants import javax.xml.validation.SchemaFactory import javax.xml.transform.stream.StreamSource if( xmlString == null ) throw new Exception(\"You must supply a pathToXMLFile parameter\"); if( xsdString == null ) throw new Exception(\"You must supply a xsd parameter\"); def factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI) def schema = factory.newSchema(new StreamSource(new StringReader(xsdString))) def validator = schema.newValidator() validator.validate(new StreamSource(new StringReader(xmlString)))" ; "isGui = false" )
Newbies nileshp789 Posted June 11, 2012 Newbies Posted June 11, 2012 thanks Alexander, it actually works okay but I find using a robust xml validator is actually, better for a newb like myself especialy with troubleshooting errors.
Opotoc Posted June 14, 2012 Author Posted June 14, 2012 For debugging I also use an editor, I use it actually in production to validate the xmls before I deliver them.
Recommended Posts
This topic is 4613 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now