use of nl.nn.adapterframework.validation.Schema in project iaf by ibissource.
the class XmlValidator method getSchemas.
@Override
public List<Schema> getSchemas(IPipeLineSession session) throws PipeRunException {
List<Schema> xsds = new ArrayList<Schema>();
String schemaLocation = getSchemasId(session);
if (schemaSessionKey != null) {
final URL url = ClassUtils.getResourceURL(classLoader, schemaLocation);
if (url == null) {
throw new PipeRunException(this, getLogPrefix(session) + "could not find schema at [" + schemaLocation + "]");
}
XSD xsd = new XSD();
xsd.setClassLoader(classLoader);
xsd.setNoNamespaceSchemaLocation(schemaLocation);
try {
xsd.init();
} catch (ConfigurationException e) {
throw new PipeRunException(this, "Could not init xsd", e);
}
xsds.add(xsd);
return xsds;
}
return null;
}
use of nl.nn.adapterframework.validation.Schema in project iaf by ibissource.
the class XmlValidator method getSchemas.
public List<Schema> getSchemas(boolean checkRootValidations) throws ConfigurationException {
Set<XSD> xsds = getXsds();
if (StringUtils.isEmpty(getNoNamespaceSchemaLocation())) {
xsds = SchemaUtils.getXsdsRecursive(xsds);
if (checkRootValidations) {
checkInputRootValidations(xsds);
checkOutputRootValidations(xsds);
}
try {
Map<String, Set<XSD>> xsdsGroupedByNamespace = SchemaUtils.getXsdsGroupedByNamespace(xsds, false);
xsds = SchemaUtils.mergeXsdsGroupedByNamespaceToSchemasWithoutIncludes(classLoader, xsdsGroupedByNamespace, null);
} catch (Exception e) {
throw new ConfigurationException(getLogPrefix(null) + "could not merge schema's", e);
}
} else {
// Support redefine for noNamespaceSchemaLocation for backwards
// compatibility. It's deprecated in the latest specification:
// http://www.w3.org/TR/xmlschema11-1/#modify-schema
// It's difficult to support redefine in
// mergeXsdsGroupedByNamespaceToSchemasWithoutIncludes so
// we only use getXsdsRecursive here for root validation. Xerces
// will need to resolve the imports, includes an redefines itself.
// See comment in method XercesXmlValidator.stringToXMLInputSource()
// too. The latest specification also specifies override:
// http://www.w3.org/TR/xmlschema11-1/#override-schema
// But this functionality doesn't seem to be (properly) supported by
// Xerces (yet). WSDL generation was the main reason to introduce
// mergeXsdsGroupedByNamespaceToSchemasWithoutIncludes, in case of
// noNamespaceSchemaLocation the WSDL generator doesn't use
// XmlValidator.getXsds(). See comment in Wsdl.getXsds() too.
Set<XSD> xsds_temp = SchemaUtils.getXsdsRecursive(xsds, false);
if (checkRootValidations) {
checkInputRootValidations(xsds_temp);
checkOutputRootValidations(xsds_temp);
}
}
List<Schema> schemas = new ArrayList<Schema>();
SchemaUtils.sortByDependencies(xsds, schemas);
return schemas;
}
Aggregations