You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by "Davanum Srinivas (JIRA)" <ji...@apache.org> on 2007/06/07 05:50:26 UTC

[jira] Updated: (AXIS2-2395) AxisMessage.getSchema() returns null when schema element is found in an imported schema

     [ https://issues.apache.org/jira/browse/AXIS2-2395?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Davanum Srinivas updated AXIS2-2395:
------------------------------------

    Assignee: Deepal Jayasinghe

> AxisMessage.getSchema() returns null when schema element is found in an imported schema
> ---------------------------------------------------------------------------------------
>
>                 Key: AXIS2-2395
>                 URL: https://issues.apache.org/jira/browse/AXIS2-2395
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>          Components: kernel
>    Affects Versions: 1.1.1
>         Environment: All
>            Reporter: Jeff Faath
>            Assignee: Deepal Jayasinghe
>            Priority: Minor
>
> When calling getSchema() on an AxisMessage, 'null' is returned when the schema element is found in an imported schema.  This is because the code does not check imported schema.  I've devised a solution below which recursively traverses any imported schema.  The original getSchema() method can be replaced by the two methods below:
> public XmlSchemaElement getSchemaElement() {
>   AxisService service = (AxisService) getParent().getParent();
>     ArrayList schemas = service.getSchema();
>     for (int i = 0; i < schemas.size(); i++) {
>       XmlSchema schema = (XmlSchema) schemas.get(i);
>       return getSchemaElement(schema);
>     }
>     return null;
> }
> private XmlSchemaElement getSchemaElement(XmlSchema schema) {
>   XmlSchemaElement returnElement = null;
>   if (schema != null) {
>     if (schema.getItems() != null) {
>       Iterator schemaItems = schema.getItems().getIterator();
>       while (schemaItems.hasNext()) {
>         Object item = schemaItems.next();
>         if (item instanceof XmlSchemaElement) {
>           XmlSchemaElement xmlSchemaElement = (XmlSchemaElement) item;
>           if (xmlSchemaElement.getQName().equals(this.elementQname)) {
>             returnElement = xmlSchemaElement;
>           }
>         }
>        else if (item instanceof org.apache.ws.commons.schema.XmlSchemaImport) {
>          returnElement = getSchemaElement(((org.apache.ws.commons.schema.XmlSchemaImport)item).getSchema());
>        }
>        else if (item instanceof org.apache.ws.commons.schema.XmlSchemaInclude) {
>          returnElement = getSchemaElement(((org.apache.ws.commons.schema.XmlSchemaInclude)item).getSchema());
>        }
>        // We've found a matching element, no need to continue...
>        if (returnElement != null)
>          break;
>        }
>      }
>    }
>    return returnElement;
>  }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org