* @see org.eclipse.wst.wsdl.validation.internal.wsdl11.IWSDL11Validator#validate(java.lang.Object, java.util.List, org.eclipse.wsdl.validate.wsdl11.WSDL11ValidationInfo)
*/
public void validate(Object element, List parents, IWSDL11ValidationInfo valInfo)
{
List elements = new ArrayList();
Schema elem = (Schema) element;
Definition wsdlDefinition = (Definition) parents.get(parents.size() - 1);
String baseLocation = wsdlDefinition.getDocumentBaseURI();
// Add in the namespaces defined in the doc already that aren't defined locally in this schema.
// There is no need to check for namespaces other then in the defintions and types elements as
// inline schema can not have any other parents and must have there two parents.
// First take care of the definitions element
// create the inline schema string
Element w3celement = elem.getElement();
Hashtable parentnamespaces = getNamespaceDeclarationsFromParents(wsdlDefinition,w3celement);
String targetNamespace = w3celement.getAttribute(Constants.ATTR_TARGET_NAMESPACE);
// if the targetNamespace hasn't been defined for the schema use the
// targetNamespace of the definitions element
if(USE_WSDL_TARGETNAMESPACE && (targetNamespace == null || targetNamespace.equals(EMPTY_STRING)))
{
targetNamespace = wsdlDefinition.getTargetNamespace();
w3celement.setAttribute(Constants.ATTR_TARGET_NAMESPACE,targetNamespace);
}
// If the namespace given is one of the old schema namespaces produce a warning.
String namespace = w3celement.getNamespaceURI();
if(namespace.equals(SchemaConstants.NS_URI_XSD_1999) || namespace.equals(SchemaConstants.NS_URI_XSD_2000))
{
valInfo.addWarning(
messagegenerator.getString(_WARN_OLD_SCHEMA_NAMESPACE, QUOTE + SchemaConstants.NS_URI_XSD_2001 + QUOTE), element);
}
// now create and call the validator for the inline schema
XSDValidator schemav = new XSDValidator();
//String fileLocation = new URL(validatormanager.getFilename()).getPath();
InlineXSDResolver inlineEntityResolver =
getEntityResolver(wsdlDefinition, (Types) parents.get(0), baseLocation, targetNamespace);
// add in the external XSD Catalog to resolve schemas offline
XMLEntityResolverChain entityResolverChain = new XMLEntityResolverChain();
entityResolverChain.addEntityResolver(inlineEntityResolver);
entityResolverChain.addEntityResolver(valInfo.getURIResolver());
//entityResolverChain.addEntityResolver(XMLCatalogResolver.getInstance());
entityResolverChain.addEntityResolver(new FileEntityResolver());
// Create the string representation of the inline schema.
String xsd = InlineSchemaGenerator.createXSDString(w3celement, elements, baseLocation, parentnamespaces, inlineEntityResolver.getInlineSchemaNSs());
schemav.validateInlineSchema(xsd, targetNamespace, baseLocation, entityResolverChain, inlineEntityResolver, valInfo.getSchemaCache());
// check if the SOAP Encoding namespace is required but not imported
if (InlineSchemaGenerator.soapEncodingRequiredNotImported(elem.getElement(), baseLocation, parentnamespaces))
{
valInfo.addWarning(messagegenerator.getString(_WARN_SOAPENC_IMPORTED_SCHEMA), element);
}
// If the schema isn't valid add the error messages produced to valinfo.