protected Schema parseSchemaInline(XMLElement schemaElement,
DescriptionElement desc)
throws WSDLException{
InlinedSchemaImpl schema = new InlinedSchemaImpl();
schema.setXMLElement(schemaElement);
schema.setId(schemaElement.getAttributeValue(Constants.ATTR_ID));
String tns = schemaElement.getAttributeValue(Constants.ATTR_TARGET_NAMESPACE);
if(tns != null) {
schema.setNamespace(getURI(tns));
}
String baseURI = desc.getDocumentBaseURI() != null ?
desc.getDocumentBaseURI().toString() : null;
XmlSchema schemaDef = null;
try {
OMElement omSchemaElem = (OMElement)schemaElement.getSource();
InputSource schemaSource = OMUtils.getInputSource(omSchemaElem);
XmlSchemaCollection xsc = new XmlSchemaCollection();
//Set the baseURI and the namespaces from the DescriptionElement in the XMLSchemaCollection
xsc.setBaseUri(baseURI);
NamespaceMap namespaces = new NamespaceMap();
Iterator it = Arrays.asList(desc.getDeclaredNamespaces()).iterator();
while(it.hasNext()) {
NamespaceDeclaration d = (NamespaceDeclaration)it.next();
namespaces.add(d.getPrefix(), d.getNamespaceURI().toString());
}
xsc.setNamespaceContext(namespaces);
// Plug in the selected woden URI Resolver
xsc.setSchemaResolver(new OMSchemaResolverAdapter(getURIResolver(), schemaElement));
schemaDef = xsc.read(schemaSource, null);
}
catch (XmlSchemaException e){
getErrorReporter().reportError(
new ErrorLocatorImpl(), //TODO line&col nos.
"WSDL521",
new Object[] {baseURI},
ErrorReporter.SEVERITY_WARNING,
e);
}
catch (RuntimeException e)
{
getErrorReporter().reportError(
new ErrorLocatorImpl(), //TODO line&col nos.
"WSDL521",
new Object[] {baseURI},
ErrorReporter.SEVERITY_ERROR,
e);
}
if(schemaDef != null) {
schema.setSchemaDefinition(schemaDef);
}
else {
schema.setReferenceable(false);
}
return schema;
}