Esempio n. 1
0
  /**
   * Get the ISchemaElement corresponding to this IDocumentElementNode
   *
   * @param node
   * @param extensionPoint the extension point of the schema, if <code>null</code> it will be
   *     deduced
   * @return the ISchemaElement for <code>node</code>
   */
  public static ISchemaElement getSchemaElement(IDocumentElementNode node, String extensionPoint) {
    if (extensionPoint == null) {
      IMonitorObject obj = getTopLevelParent(node);
      if (!(obj instanceof IMonitorExtension)) return null;
      extensionPoint = ((IMonitorExtension) obj).getPoint();
    }
    ISchema schema = MDECore.getDefault().getSchemaRegistry().getSchema(extensionPoint);
    if (schema == null) return null;

    // Bug 213457 - look up elements based on the schema in which the parent is found
    if (schema.getIncludes().length == 0 || "extension".equals(node.getXMLTagName())) // $NON-NLS-1$
    return schema.findElement(node.getXMLTagName());

    // if element is not "extension" & has multiple sub-schemas,
    // Then search for the element in the same schema in which the parent element if found.
    Stack stack = new Stack();
    while (node != null) {
      String tagName = node.getXMLTagName();
      if ("extension".equals(tagName)) // $NON-NLS-1$
      break;
      stack.push(node.getXMLTagName());
      node = node.getParentNode();
    }
    ISchemaElement element = null;
    while (!stack.isEmpty()) {
      element = schema.findElement((String) stack.pop());
      if (element == null) return null;
      schema = element.getSchema();
    }
    return element;
  }
Esempio n. 2
0
  /**
   * Get the ISchemaAttribute corresponding to this IDocumentAttributeNode
   *
   * @param attr
   * @param extensionPoint the extension point of the schema, if <code>null</code> it will be
   *     deduced
   * @return the ISchemaAttribute for <code>attr</code>
   */
  public static ISchemaAttribute getSchemaAttribute(
      IDocumentAttributeNode attr, String extensionPoint) {
    ISchemaElement ele = getSchemaElement(attr.getEnclosingElement(), extensionPoint);
    if (ele == null) return null;

    return ele.getAttribute(attr.getAttributeName());
  }
Esempio n. 3
0
 public static String getCounterKey(ISchemaElement elementInfo) {
   return elementInfo.getSchema().getQualifiedPointId()
       + "."
       + elementInfo.getName(); // $NON-NLS-1$
 }