} }  for (Iterator i = getReferencingDirectives().iterator(); i.hasNext(); ) { XSDSchemaDirective xsdSchemaDirective = (XSDSchemaDirective)i.next(); if (xsdSchemaDirective.getContainer() == null || xsdSchemaDirective.getResolvedSchema() != this && (!(xsdSchemaDirective instanceof XSDSchemaCompositor) || ((XSDSchemaCompositor)xsdSchemaDirective).getIncorporatedSchema() != this)) { i.remove();
  protected void patch()  {    incorporatingSchemas = null;        if (XSDConstants.isSchemaForSchemaNamespace(getTargetNamespace()))    {      XSDSchema magicSchemaForSchema = getMagicSchemaForSchema(getTargetNamespace());      if (magicSchemaForSchema != this)      {        XSDNamedComponentImpl.addToSortedList          (getTypeDefinitions(), (XSDSimpleTypeDefinition)magicSchemaForSchema.getTypeDefinitions().get(0));      }    }    else    {      Collection xsiSchemas = resolveSchema(XSDConstants.SCHEMA_INSTANCE_URI_2001);      if (xsiSchemas.size() == 1)      {        XSDNamedComponentImpl.mergeToSortedList          (getAttributeDeclarations(),            ((XSDSchema)xsiSchemas.iterator().next()).getAttributeDeclarations());      }    }    super.patch();        List schemasToPatch = new ArrayList();    schemasToPatch.add(this);    for (int i = 0; i < schemasToPatch.size(); ++i)    {      XSDSchema xsdSchema = (XSDSchema)schemasToPatch.get(i);       for (Iterator j = xsdSchema.getContents().iterator(); j.hasNext(); )      {        XSDConcreteComponent content = (XSDConcreteComponent)j.next();        if (content instanceof XSDSchemaDirective)        {          if (content instanceof XSDSchemaCompositor)          {            XSDSchemaCompositor xsdSchemaCompositor = (XSDSchemaCompositor)content;            XSDSchemaImpl xsdIncorporatedSchema =  (XSDSchemaImpl)xsdSchemaCompositor.getIncorporatedSchema();            if (xsdIncorporatedSchema != null && !schemasToPatch.contains(xsdIncorporatedSchema))            {              schemasToPatch.add(xsdIncorporatedSchema);              xsdIncorporatedSchema.patchContents();            }          }        }        else if (!(content instanceof XSDAnnotation))        {          break;        }      }    }        if (schemaLocation != null)    {      analyze();    }  }