weinmang
15 years agoNew Contributor
Groovy XML Validation with multiple imported schemas
Validating an XML document against a schema having multiple cascading schema imports each in their own namespace works in Java ...factory.newSchema(new Source[]...
However, attempting to use a source array to create a schema with the schema factory yields
java.lang.ClassCastException: [Ljava.util.ArrayList; cannot be cast to java.util.List [Ljava.util.ArrayList; cannot be cast to java.util.List
A snippet of my code follows:
def resultFIS = new StreamSource(new FileInputStream(resultXSD))
def profileFIS = new StreamSource(new FileInputStream(profileXSD))
def pageFIS = new StreamSource(new FileInputStream(pageXSD))
def appFIS = new StreamSource(new FileInputStream(appXSD))
def commonFIS = new StreamSource(new FileInputStream(commonXSD))
def schemaFiles = [commonFIS, appFIS, pageFIS, profileFIS, resultFIS]
def factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI)
def schema = factory.newSchema(schemaFiles)
The error message is confusing. I hope it's something simple.
However, attempting to use a source array to create a schema with the schema factory yields
java.lang.ClassCastException: [Ljava.util.ArrayList; cannot be cast to java.util.List [Ljava.util.ArrayList; cannot be cast to java.util.List
A snippet of my code follows:
def resultFIS = new StreamSource(new FileInputStream(resultXSD))
def profileFIS = new StreamSource(new FileInputStream(profileXSD))
def pageFIS = new StreamSource(new FileInputStream(pageXSD))
def appFIS = new StreamSource(new FileInputStream(appXSD))
def commonFIS = new StreamSource(new FileInputStream(commonXSD))
def schemaFiles = [commonFIS, appFIS, pageFIS, profileFIS, resultFIS]
def factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI)
def schema = factory.newSchema(schemaFiles)
The error message is confusing. I hope it's something simple.