}
private void doSchemaValidation(InputSource wsdlsource, byte[] bytes, Document doc,
StackTraceErrorHandler handler) throws IOException, SAXException {
if (isSchemaDocument(doc)) {
XSGrammar xsGrammer = (XSGrammar)preparser.preparseGrammar(XMLGrammarDescription.XML_SCHEMA,
copyInputSourceXML(wsdlsource, bytes));
xsmodelList.add(xsGrammer.toXSModel());
} else {
Map schemas = serializeSchemaElements(doc);
SchemaEntityResolver schemaResolver = (SchemaEntityResolver)preparser.getEntityResolver();
schemaResolver.setSchemas(schemas);
Iterator it = schemas.keySet().iterator();
while (it.hasNext()) {
String tns = (String)it.next();
byte[] schemaBytes = (byte[])schemas.get(tns);
WSDLSchemaErrorHandler schemaHandler = new WSDLSchemaErrorHandler(handler, schemaBytes, doc
.getXmlEncoding());
try {
preparser.setErrorHandler(schemaHandler);
XSGrammar xsGrammer = (XSGrammar)preparser
.preparseGrammar(XMLGrammarDescription.XML_SCHEMA,
copyInputSourceXML(wsdlsource, tns, schemaBytes, doc
.getXmlEncoding()));
xsmodelList.add(xsGrammer.toXSModel());
} finally {
preparser.setErrorHandler(handler);
}
}