Forum Discussion
TanyaYatskovska
Alumni
10 years agoHi Harsh1,
Please check if the following sample code posted to stackoverflow helps you:
import javax.xml.XMLConstants
import javax.xml.transform.stream.StreamSource
import javax.xml.validation.SchemaFactory
xsdUrl = 'http://abbot.sourceforge.net/doc/abbot.xsd'
xmlUrl = 'http://abbot.sourceforge.net/src/example/SimpleApplet.xml'
new URL( xsdUrl ).withInputStream { xsd ->
new URL( xmlUrl ).withInputStream { xml ->
SchemaFactory.newInstance( XMLConstants.W3C_XML_SCHEMA_NS_URI )
.newSchema( new StreamSource( xsd ) )
.newValidator()
.validate( new StreamSource( xml ) )
}
}