Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
<copyright> Copyright (c) 2002-2007 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: IBM - Initial API and implementation </copyright> $Id: XSDItemProviderAdapter.java,v 1.9 2007/03/22 02:06:23 davidms Exp $
  
  package org.eclipse.xsd.provider;
  
  
  import java.util.HashSet;
  import java.util.List;
  
  
This is the base for all adapters. It takes handles the getParent() implementation that is need for XSDParticleItemProvider and XSDAttributeUseItemProvider to skip up to a particle or attribute use. It also supports org.eclipse.emf.edit.command.CreateChildCommand by supplying text and icons, and provides methods that assist the derived adapters in overriding org.eclipse.emf.edit.provider.ItemProviderAdapter.collectNewChildDescriptors(java.util.Collection,java.lang.Object).
  
  public class XSDItemProviderAdapter extends ItemProviderAdapter
    implements CreateChildCommand.Helper
  {
    protected static final XSDPackage xsdPackage = .;
    protected static final XSDFactory xsdFactory = .;
  
This creates an instance from an adapter factory.
  
    protected XSDItemProviderAdapter(AdapterFactory adapterFactory)
    {
      super(adapterFactory);
       = new AdapterFactoryItemDelegator(adapterFactory);
    }

  
This returns the parent.
  
    @Override
    public Object getParent(Object object)
    {
      EObject parent = ((EObject)object).eContainer();
      if (parent != null)
      {
        EObject grandParent = parent.eContainer();
       if (grandParent instanceof XSDParticle ||
           grandParent instanceof XSDAttributeUse)
       {
         return grandParent;
       }
     }
     return parent;
   }
 
   {
     if ( == null)
     {
        = 
         new ArrayList<IItemPropertyDescriptor>()
         {
           private static final long serialVersionUID = 1L;
 
           @Override
           public boolean add(IItemPropertyDescriptor o)
           {
             String id = o.getId(object);
             for (IItemPropertyDescriptor propertyDescriptor : this)
             {
               if (id.equals(propertyDescriptor.getId(object)))
               {
                 return false;
               }
             }
             return super.add(o);
           }
         };
 
     }
     return ;
   }
 
   public static class ItemPropertyDescriptorWithDefault extends ItemPropertyDescriptor
   {
        (AdapterFactory adapterFactory,
         String displayName,
         String description,
         EStructuralFeature feature,
         boolean isSettable,
         Object staticImage)
     {
       super(adapterFactorydisplayNamedescriptionfeatureisSettablestaticImage);
     }
 
     @Override
     public Object getPropertyValue(Object o)
     {
       if ( instanceof EAttribute)
       {
         EObject refObject = (EObject)o;
         EAttribute attribute = (EAttribute);
         if (!attribute.isMany() && !refObject.eIsSet(attribute))
         {
           return createPropertyValueWrapper(ogetPropertyDefaultValue(o));
         }
       }
       return super.getPropertyValue(o);
     }
 
     @Override
     public void setPropertyValue(Object oObject value)
     {
       if ( instanceof EAttribute)
       {
         EAttribute attribute = (EAttribute);
         if (!attribute.isMany())
         {
           Object propertyDefaultValue = getPropertyDefaultValue(o);
           if (propertyDefaultValue.equals(value))
           {
             resetPropertyValue(o);
             return;
           }
         }
       }
       super.setPropertyValue(ovalue);
     }
 
     @Override
     public Collection<?> getChoiceOfValues(Object o)
     {
       Collection<?> result = super.getChoiceOfValues(o);
       if (result != null &&  instanceof EAttribute)
       {
         EAttribute attribute = (EAttribute);
         if (!attribute.isMany())
         {
           List<ObjectnewResult = new ArrayList<Object>(result);
           Object propertyDefaultValue = getPropertyDefaultValue(o);
           newResult.add(propertyDefaultValue);
           result = newResult;
         }
       }
       return result;
     }
 
     {
       if ( instanceof EAttribute)
       {
         EAttribute attribute = (EAttribute);
         if (!attribute.isMany())
         {
           Object result = attribute.getDefaultValue();
           if (result == null)
           {
             result = getDefaultValue(attribute.getEType());
           }
           if (result == null)
           {
             return ..getString("_UI_DefaultValue_label"new Object [] { "" });
           }
           else
           {
             return ..getString("_UI_DefaultValue_label"new Object [] { this..getText(result) });
           }
         }
       }
       return null;
     }
   }

  
If object is a particle or an attribute use, this returns its content; otherwise, object itself.
 
   {
     if (object instanceof XSDParticle)
     {
       return ((XSDParticleobject).getContent();
     }
     else if (object instanceof XSDAttributeUse)
     {
       return ((XSDAttributeUseobject).getContent();
     }
     return object;
   }

  
This is a convenience method for creating CommandParameters for a given parent feature and child object.
 
                                                   XSDConcreteComponent child)
   {
     return new CommandParameter(nullfeaturechild);
   }

  
This is a convenience method for creating org.eclipse.emf.edit.command.CommandParameters for model groups of two or all of the three compositor types (choice, sequence, and optionally all, depending on the value of all) and adding them to a newChildDescriptors collection. If useParticle is true, each model group will be the content of a new particle.
 
   protected void addModelGroupChildParameters(Collection<ObjectnewChildDescriptors,
                                               EReference feature,
                                               boolean all,
                                               boolean useParticle)
   {
     for (int i = all ? 0 : 1; i < compositor.lengthi++)
     {
       mg.setCompositor(compositor[i]);
       XSDConcreteComponent child = mg;
       if (useParticle)
       {
         child = createParticle(mgfalse);
       }
       newChildDescriptors.add(createChildParameter(featurechild));
     }
   }

  
This is a convenience method for creating org.eclipse.emf.edit.command.CommandParameters for simple type definitions of zero, one, two, or all of three varieties (atomic, list, and union), and adding them to a newChildDescriptors collection. The simple type definition objects are to be added to the specified feature of parent. The varieties for which to create simple type definitions and command parameters are specified by the three boolean arguments, atomic, list, and union.
 
     (Collection<ObjectnewChildDescriptors
      XSDConcreteComponent parent,
      EReference feature
      boolean atomic
      boolean list
      boolean union)
   {
     XSDSchema xsdSchema = parent.getSchema();
     if (xsdSchema != null)
     {
   
       if (atomic)
       {
         XSDSimpleTypeDefinition xsdSimpleTypeDefinition = createSimpleTypeDefinition(parent);
         xsdSimpleTypeDefinition.setVariety(.);
         xsdSimpleTypeDefinition.setBaseTypeDefinition(baseType);
         newChildDescriptors.add(createChildParameter(featurexsdSimpleTypeDefinition));
       }
   
       if (list)
       {
         XSDSimpleTypeDefinition xsdSimpleTypeDefinition = createSimpleTypeDefinition(parent);
         xsdSimpleTypeDefinition.setVariety(.);
         xsdSimpleTypeDefinition.setItemTypeDefinition(baseType);
         newChildDescriptors.add(createChildParameter(featurexsdSimpleTypeDefinition));
       }
   
       if (union)
       {
         XSDSimpleTypeDefinition xsdSimpleTypeDefinition = createSimpleTypeDefinition(parent);
         xsdSimpleTypeDefinition.setVariety(.);
         xsdSimpleTypeDefinition.getMemberTypeDefinitions().add(baseType);
         newChildDescriptors.add(createChildParameter(featurexsdSimpleTypeDefinition));
       }
     }
   }

  
This determines whether an object represents a global element, based on the type of its parent.
 
   protected boolean isGlobal(Object parent)
   {
     return (parent instanceof XSDSchema || parent instanceof XSDRedefine);
   }

  
This creates an object of type XSDAttributeDeclaration with a name that is unique globally (compared to other global attribute declarations) or locally (compared to sibling attribute declarations and children of sibling attribute groups), depending on the type of the specified parent. The created object will be initialized to resolve to itself and to have the string type definition.

Note: in determining local uniqueness, we do not consider any referenced uses of the parent group or type elsewhere in the schema.

 
   {
     XSDAttributeDeclaration child = null;
     
     if (isGlobal(parent))
     {
       String name = null;
       int i = 0;
       do
       {
         name = baseName + ((i > 0) ? String.valueOf(i) : "");
         i = (i > 0) ? i + 1 : 1;
         child = parent.resolveAttributeDeclaration(name);
       } while (((EObjectchild).eContainer() != null);
     }
     else
     {
       XSDSchema schema = parent.getSchema();
 
       // use the namespace from the schema in determining local uniqueness
       // only if new local declarations will be qualified by default
       String namespace = null;
       if (schema != null &&
           schema.getAttributeFormDefault() == .)
       {
         namespace = schema.getTargetNamespace();
       }
       Collection<? extends XSDAttributeUsesiblings = getAttributeSiblings(parent);
       String name = null;
       int i = 0;
       do
       {
         name = baseName + ((i > 0) ? String.valueOf(i) : "");
         i = (i > 0) ? i + 1 : 1;
       } while (!isUniqueAttributeDeclarationName(namenamespacesiblings));
       
       child = .createXSDAttributeDeclaration();
       child.setName(name); 
       if (namespace != null)
       {
         child.setTargetNamespace(namespace);
       }
       child.setResolvedAttributeDeclaration(child);
     }
     
     // initialize element type to be string
     return child;
   }
  
  
This gathers and returns the siblings by stepping up through any attribute group definitions to the top-most parent attribute definition or complex type definition, and returning the attribute uses for it. Returns null if there is no such parent.
 
   {
     Collection<XSDAttributeUsesiblings = null;
     if (parent instanceof XSDAttributeGroupDefinition)
     {
       while (group.eContainer() instanceof XSDAttributeGroupDefinition)
       {
         group = (XSDAttributeGroupDefinitiongroup.eContainer();
       }
 
       if (group.eContainer() instanceof XSDComplexTypeDefinition)
       {
         parent = (XSDComplexTypeDefinitiongroup.eContainer();
       }
       else
       {
         siblings = group.getAttributeUses();
       }
     }
     if (parent instanceof XSDComplexTypeDefinition)
     {
       siblings = ((XSDComplexTypeDefinitionparent).getAttributeUses();
     }
     return siblings;
   }

  
This tests whether the combination of given localName and targetNamespace is shared by an attribute declaration of an attribute use in the given collection. Returns false if so, true otherwise. Note that this method is tolerant of nulls: a result of true is returned if attributeUse is null, and two null strings are considered equal.
 
   protected boolean isUniqueAttributeDeclarationName(String localNameString targetNamespaceCollection<? extends XSDAttributeUseattributeUses)
   {
     if (attributeUses != null)
     {
       for (XSDAttributeUse attributeUse : attributeUses)
       {
         if (attributeUse.getAttributeDeclaration() != null)
         {
           XSDAttributeDeclaration other = 
             attributeUse.getAttributeDeclaration();
           if (other.hasNameAndTargetNamespace(localNametargetNamespace))
           {
             return false;
           }
         }
       }
     }
     return true;
   }

  
This creates an object of type XSDElementDeclaration with a name that is unique globally or locally, depending on the type of the specified parent. The created object will be initialized to resolve to itself and to have the string type definition.

Note: in determining local uniqueness, we do not consider any referenced uses of the parent group or type elsewhere in the schema.

 
   {
     XSDElementDeclaration child = null;
 
     if (isGlobal(parent))
     {
       String name = null;
       int i = 0;
       do
       {
         name = baseName + ((i > 0) ? String.valueOf(i) : "");
         i = (i > 0) ? i + 1 : 1;
         child = parent.resolveElementDeclaration(name);
       } while (((EObjectchild).eContainer() != null);
     }
     else
     {
       XSDSchema schema = parent.getSchema();
 
       // use the namespace from the schema in determining local uniqueness
       // only if new local declarations will be qualified by default
       String namespace = null;
       if (schema != null &&
           schema.getElementFormDefault() == .)
       {
         namespace = schema.getTargetNamespace();
       }
       XSDModelGroup modelGroup = getTopModelGroup(parent);
       String name = null;
       int i = 0;
       do
       {
         name = baseName + ((i > 0) ? String.valueOf(i) : "");
         i = (i > 0) ? i + 1 : 1;
       } while (!isUniqueElementDeclarationName(namenamespacemodelGroupnull));
       child = .createXSDElementDeclaration();
       child.setName(name);
       if (namespace != null)
       {
         child.setTargetNamespace(namespace);
       }
       child.setResolvedElementDeclaration(child);
     }
 
     // initialize attribute type to be string
     return child;
   }

  
If the specified parent is a model group, this finds and returns the top-most model group above it (within the same complex type or model group definition). Otherwise, returns null.
 
   {
     XSDModelGroup modelGroup = null;
 
     if (parent instanceof XSDModelGroup)
     {
       modelGroup = (XSDModelGroupparent;
       while (parent.eContainer() instanceof XSDParticle ||
              parent.eContainer() instanceof XSDModelGroup)
       {
         parent = (XSDConcreteComponentparent.eContainer();
         if (parent instanceof XSDModelGroup)
         {
           modelGroup = (XSDModelGroupparent;
         }
       }
     }
     return modelGroup;
   }

  
This tests whether the combination of given localName and targetNamespace is shared by an element declaration in the given model group or a model group under it. Returns false if so, true otherwise. Note that this method is tolerant of nulls: a result of true is returned if modelGroup is null, and two null strings are considered equal. Also, note that the visited argument is used to avoid an infinite recursion situation, and should be null when the method is initially called.
 
   protected boolean isUniqueElementDeclarationName(String localNameString targetNamespaceXSDModelGroup modelGroupHashSet<XSDModelGroupvisited)
   {
     if (visited == null)
     {
       visited = new HashSet<XSDModelGroup>();
     }
 
     if (modelGroup != null && visited.add(modelGroup) && modelGroup.getParticles() != null)
     {
       for (XSDParticle particle : modelGroup.getParticles())
       {
         if (particle.getTerm() instanceof XSDElementDeclaration)
         {
           XSDElementDeclaration other = 
             (XSDElementDeclarationparticle.getTerm();
           if (other.hasNameAndTargetNamespace(localNametargetNamespace))
           {
             return false;
           }
         }
         else if (particle.getTerm() instanceof XSDModelGroup)
         {
           XSDModelGroup others = (XSDModelGroupparticle.getTerm();
           if (!isUniqueElementDeclarationName(localNametargetNamespaceothersvisited))
           {
             return false;
           }
         }
       }
     }
     return true;
   }

  
This creates an object of type XSDAttributeGroupDefinition with a name that is unique globally, and that resolves to itself. The created object is to be added under the specified parent.
 
   {
     XSDAttributeGroupDefinition child = null;
     String name = null;
     int i = 0;
     do
     {
       name = baseName + ((i > 0) ? String.valueOf(i) : "");
       i = (i > 0) ? i + 1 : 1;
       child = parent.resolveAttributeGroupDefinition(name);
     } while (((EObjectchild).eContainer() != null);
 
     return child;
   }

  
This creates an object of type XSDModelGroupDefinition with a name that is unique globally, and that resolves to itself. The created object is to be added under the specified parent.
 
   {
     XSDModelGroupDefinition child = null;
     String name = null;
     int i = 0;
     do
     {
       name = baseName + ((i > 0) ? String.valueOf(i) : "");
       i = (i > 0) ? i + 1 : 1;
       child = parent.resolveModelGroupDefinition(name);
     } while (((EObjectchild).eContainer() != null);
 
     return child;
   }

  
This creates an object of type XSDComplexTypeDefinition with a name that is unique globally, if this is to be a global definition; otherwise, with no name. The created object is to be added under the specified parent.
 
   {
     XSDComplexTypeDefinition child = null;
 
     if (isGlobal(parent))
     {
       String name = null;
       int i = 0;
       do
       {
         name = baseName + ((i > 0) ? String.valueOf(i) : "");
         i = (i > 0) ? i + 1 : 1;
         child = parent.resolveComplexTypeDefinition(name);
       } while (((EObjectchild).eContainer() != null);
     }
     else
     {
     }
     return child;
   }

  
This creates an object of type XSDSimpleTypeDefinition with a name that is unique globally, if this is to be a global definition; otherwise, with no name. The created object is to be added under the specified parent.
 
   {
     XSDSimpleTypeDefinition child = null;
 
     if (isGlobal(parent))
     {
       String name = null;
       int i = 0;
       do
       {
         name = baseName + ((i > 0) ? String.valueOf(i) : "");
         i = (i > 0) ? i + 1 : 1;
         child = parent.resolveSimpleTypeDefinition(name);
       } while (((EObjectchild).eContainer() != null);
     }
     else
     {
       child = .createXSDSimpleTypeDefinition();
     }
 
     return child;
   }

  
This creates an object of type XSDIdentityConstraintDefinition with a name that is unique globally. The created object is to be added under the specified parent.
 
   {
     XSDIdentityConstraintDefinition child = null;
     String name = null;
     int i = 0;
     do
     {
       name = baseName + ((i > 0) ? String.valueOf(i) : "");
       i = (i > 0) ? i + 1 : 1;
       child = parent.resolveIdentityConstraintDefinition(name);
     } while (((EObjectchild).eContainer() != null);
 
     return child;
   }

  
This creates an object of type XSDNotationDeclaration with a name that is unique globally. The created object, to be added under the specified parent, will have an empty string as its public identifier.
 
   {
     XSDNotationDeclaration child = null;
     String name = null;
     int i = 0;
     do
     {
       name = baseName + ((i > 0) ? String.valueOf(i) : "");
       i = (i > 0) ? i + 1 : 1;
       child = parent.resolveNotationDeclaration(name);
     } while (((EObjectchild).eContainer() != null);
 
     child.setPublicIdentifier("");
     return child;
   }

  
This creates an object of type XSDAttributeUse containing an object of type XSDAttributeDeclaration -- if isReference is true, the attribute use content will be a new attribute declaration that resolves to attributeDeclaration; otherwise, it will be simply attributeDeclaration itself.
 
   protected XSDAttributeUse createAttributeUse(XSDAttributeDeclaration attributeDeclarationboolean isReference)
   {
     if (isReference)
     {
       ref.setResolvedAttributeDeclaration(attributeDeclaration);
       au.setContent(ref);
     }
     else
     {
       au.setContent(attributeDeclaration);
     }
     return au;
   }

  
This creates an object of type XSDAttributeGroupDefinition that resolves to attributeGroupDefinition.
 
   {
     ref.setResolvedAttributeGroupDefinition(attributeGroupDefinition);
     return ref;
   }

  
This creates an object of type XSDParticle containing an object of type XSDParticleContent -- if either particleContent is an element declaration and isReference is true or particleContent is a model group definition, the particle content will be a new element declaration that resolves to particleContent; otherwise, it will be simply particleContent itself.
 
   protected XSDParticle createParticle(XSDParticleContent particleContentboolean isReference)
   {
     if (particleContent instanceof XSDModelGroupDefinition)
     {
       ref.setResolvedModelGroupDefinition((XSDModelGroupDefinitionparticleContent);
       p.setContent(ref);
     }
     else if (particleContent instanceof XSDElementDeclaration && isReference)
     {
       ref.setResolvedElementDeclaration((XSDElementDeclarationparticleContent);
       p.setContent(ref);
     }
     else
     {
       p.setContent(particleContent);
 
     }
     return p;
   }

  
This returns the translated name for a new object with the specified type name.
 
   protected String getNewObjectName(String typeName)
   {
     return ..getString("_UI_" + typeName + "_new_object");
   }

  
This returns the default result collection for org.eclipse.emf.edit.command.CreateChildCommand.
 
   public Collection<?> getCreateChildResult(Object child)
   {
     Collection<Objectresult = new ArrayList<Object>(1);
     result.add(child);
     return result;
   }

  
This returns the translated label for org.eclipse.emf.edit.command.CreateChildCommand.
 
   public String getCreateChildText(Object parentObject feature,
                                    Object childCollection<?> selection)
   {
     child = getParticleOrAttributeUseContent(child);
 
     EReference refFeature = feature instanceof EReference ?
       (EReferencefeature : null;
     String qualifier = getTypeTextQualifier(parentrefFeaturechild);
 
     return getTypeText(childqualifier);
   }

  
This returns the translated description for org.eclipse.emf.edit.command.CreateChildCommand.
 
   public String getCreateChildDescription(Object parentObject feature,
                                           Object childCollection<?> selection)
   {
     child = getParticleOrAttributeUseContent(child);
 
     EReference refFeature = feature instanceof EReference ?
       (EReferencefeature : null;
     String qualifier = getTypeTextQualifier(parentrefFeaturechild);
 
     Object selectedObject = selection == null || selection.isEmpty() ?
       null : getParticleOrAttributeUseContent(selection.iterator().next());
     if (parent != selectedObject)
     {
       return 
           ("_UI_CreateSibling_description"new Object [] { getTypeText(childqualifier), getTypeText(selectedObjectnull) });
     }
     else
     {
       return 
           ("_UI_CreateChild_description"new Object [] { getTypeText(childqualifier), getTypeText(parentnull) });
     }
   }

  
This returns the translated tool tip for org.eclipse.emf.edit.command.CreateChildCommand.
 
   public String getCreateChildToolTipText(Object parentObject feature,
                                           Object childCollection<?> selection)
   {
     child = getParticleOrAttributeUseContent(child);
 
     EReference refFeature = feature instanceof EReference ?
       (EReferencefeature : null;
     String qualifier = getTypeTextQualifier(parentrefFeaturechild);
 
     Object selectedObject = selection == null || selection.isEmpty() ?
       null : getParticleOrAttributeUseContent(selection.iterator().next());
     if (parent != selectedObject)
     {
       return 
           ("_UI_CreateSibling_tooltip"new Object [] { getTypeText(childqualifier), getTypeText(selectedObjectnull) });
     }
     else
     {
       return 
           ("_UI_CreateChild_tooltip"new Object [] { getTypeText(childqualifier), getTypeText(parentnull) });
     }
   }

  
This gets the translated string for object's type, qualified by qualifier, if it is non-null.
 
   protected String getTypeText(Object objectString qualifier)
   {
     StringBuffer typeKey = new StringBuffer("_UI_");
     typeKey.append(object instanceof EObject ?
                    ((EObjectobject).eClass().getName() : "Unknown");
     typeKey.append("_type");
 
     if (qualifier != null)
     {
       typeKey.append('_');
       typeKey.append(qualifier);
     }
     return ..getString(typeKey.toString());
   }  

  
 
   public Object getCreateChildImage(Object parentObject feature,
                                     Object childCollection<?> selection)
   {
     child = getParticleOrAttributeUseContent(child);
     Object image = null;
 
     if (child instanceof EObject)
     {
       StringBuffer imageName = new StringBuffer("full/obj16/");
       String typeName = ((EObjectchild).eClass().getName();
 
       EReference refFeature = feature instanceof EReference ?
         (EReferencefeature : null;
       String qualifier = getImageNameQualifier(parentrefFeaturechild);
 
       // kludge: drop Declaration or Definition when qualifier is Use
       int i = "Use".equals(qualifier) ? typeName.lastIndexOf('D') : 0;
       if (i > 0)
       {
         typeName = typeName.substring(0, i);
       }
       imageName.append(typeName);
 
       if (qualifier != null)
       {
         imageName.append(qualifier);
       }
       image = ..getImage(imageName.toString());    
     }
     return image;
   }

  
This generates and returns a qualifier string, for use in forming the type key, based on the state of the child object, its parent, and the feature under which it is to be added.
 
   protected String getTypeTextQualifier(Object parentEReference feature,
                                         Object child)
   {
     return getQualifier(parentfeaturechild);
   }    

  
This generates and returns a qualifier string, for use in forming the icon filename, based on the state of the child object, its parent, and the feature under which is to be added.
 
   protected String getImageNameQualifier(Object parentEReference feature,
                                          Object child)
   {
     // kludge: there is only one annotation icon
     Object p = child instanceof XSDAnnotation ? null : parent;      
     String qualifier = getQualifier(pfeaturechild);
       
     // a little translation
     if ("keyref".equals(qualifier))
     {
       qualifier = "KeyReference";
     }
     else if ("reference".equals(qualifier))
     {
       qualifier = "Use";
     }
     else if (qualifier != null && qualifier.length() > 0)
     {
       // capitalize
       StringBuffer buffer = new StringBuffer(qualifier);
       char c = buffer.charAt(0);
      buffer.setCharAt(0, Character.toUpperCase(c));
      qualifier = buffer.toString();
    }
    return qualifier;
  }

  
This does common stuff for getTypeTextQualifier() and getImageNameQualifier().
  private String getQualifier(Object parentEReference featureObject child)
  {
    String qualifier = null;
    // qualification for feature declaration or group definition reference
    if ((child instanceof XSDElementDeclaration &&
         ((XSDElementDeclarationchild).isElementDeclarationReference()) ||
        (child instanceof XSDAttributeDeclaration &&
        (child instanceof XSDModelGroupDefinition &&
        (child instanceof XSDAttributeGroupDefinition &&
         ((XSDAttributeGroupDefinition
          child).isAttributeGroupDefinitionReference()))
    {    
      qualifier = "reference";
    }
    // qualification by compositor for model group
    else if (child instanceof XSDModelGroup)
    {
      qualifier = ((XSDModelGroupchild).getCompositor().getName();
    }
    // qualification by variety for simple type definition
    else if (child instanceof XSDSimpleTypeDefinition)
    {
      qualifier = ((XSDSimpleTypeDefinitionchild).getVariety().getName();
    }
    // qualification by category for identity constraint definition
    else if (child instanceof XSDIdentityConstraintDefinition)
    {
    }
    // qualification by variety for xpath definition
    else if (child instanceof XSDXPathDefinition)
    {
      qualifier = ((XSDXPathDefinitionchild).getVariety().getName();
    }
    // qualification according to parent for wildcard
    else if (child instanceof XSDWildcard)
    {
      if (parent instanceof XSDAttributeGroupDefinition ||
          parent instanceof XSDComplexTypeDefinition)
      {
        qualifier = "attribute";
      }
      else if (parent instanceof XSDModelGroup)
      {
        qualifier = "element";
      }
    }
    // qualification by feature name for annotation under type definition
    else if (child instanceof XSDAnnotation &&
             parent instanceof XSDTypeDefinition &&
             feature != null)
    {
      qualifier = feature.getName();
    }
    return qualifier;
  }