public XSDTypeDefinition resolveTypeDefinition(String namespace, String localName) { XSDTypeDefinition result = null; for (Iterator i = resolveSchema(namespace).iterator(); i.hasNext();) { XSDSchema schema = (XSDSchema)i.next(); result = schema.resolveTypeDefinition(namespace, localName); if (isComponentDefined(result)) return result; } // Could not resolve. Try against all <import>ed and inlined schemas. for (Iterator i = getImportedOrInlinedSchemas().iterator(); i.hasNext();) { XSDSchema schema = (XSDSchema)i.next(); result = schema.resolveTypeDefinition(namespace, localName); if (isComponentDefined(result)) return result; } return result; // Failed to resolve. }
static XSDParticle particle(XSDSchema schema, String elementName, String typeNS, String typeName, boolean nillable, int minOccurs, int maxOccurs) { XSDFactory factory = XSDFactory.eINSTANCE; XSDElementDeclaration element = factory.createXSDElementDeclaration(); element.setName(elementName); element.setNillable(nillable); XSDTypeDefinition type = schema.resolveTypeDefinition(typeNS, typeName); element.setTypeDefinition(type); XSDParticle particle = factory.createXSDParticle(); particle.setMinOccurs(minOccurs); particle.setMaxOccurs(maxOccurs); particle.setContent(element); return particle; }