/**
   * Create a symbolic reference which contains an ocl condition which holds the criteria for the
   * referenced model element given in the parameter.
   *
   * @param self The element which should be referenced.
   * @param contextDepth The depth for which context references should be created. If <code>0</code>
   *     , then no context reference is created.
   * @return A symbolic reference to the model element.
   */
  public ElementSetReference create(EObject self, int contextDepth) {
    final ElementSetReference ref = SymrefsFactory.eINSTANCE.createElementSetReference();
    ref.setType(self.eClass());
    ref.setUriReference(QvtlibHelper.getUriString(self));
    ref.setLabel(QvtlibHelper.getLabel(self));
    ref.getConditions().add(createOclCondition(self));

    // the context can of course only be set if the parent exists
    if (contextDepth > 0 && self.eContainer() != null) {
      ref.setContext(create(self.eContainer(), contextDepth - 1));
    }

    return ref;
  }