private SingletonMap moveNsDeclaration(BpelEntity entity, Attr attr)
      throws InvalidNamespaceException {
    String namespaceURI = attr.getValue();
    ExNamespaceContext context = entity.getNamespaceContext();
    /*
     * Fantom addition of namespace. This call will not do anything,
     * it just check correcttness of namespaceURI. If it bad then
     * InvalidNamespaceException will appear and we go to catch.
     */
    context.addNamespace(namespaceURI);

    // here we remove namespace declararation
    ((BpelEntityImpl) entity)
        .setAttribute(attr.getName(), new PrefixAttribute(attr.getName()), null);

    String localName = attr.getLocalName();
    Iterator<String> iterator = context.getPrefixes();
    boolean usePrefix = true;
    while (iterator.hasNext() && localName != null) {
      String prefix = iterator.next();
      if (localName.equals(prefix)) {
        usePrefix = false;
      }
    }
    String prefix = null;
    if (XMLNS.equals(attr.getName()) || localName == null || !usePrefix) {
      prefix = context.addNamespace(attr.getValue());
    } else {
      prefix = localName;
      context.addNamespace(localName, attr.getValue());
    }
    return new SingletonMap(localName, prefix);
  }
 private void handleNsAttribute(
     BpelEntity entity, BpelEntity parent, Map<String, String> prefixMap, Attr attr) {
   String namespaceURI = attr.getValue();
   if (XMLNS.equals(attr.getName()) || (XMLNS.equals(attr.getPrefix()))) {
     if (namespaceURI.equals(entity.getPeer().getNamespaceURI())) {
       // do not touch namespace that correspond namespace of current element
       return;
     }
     ExNamespaceContext context = parent.getNamespaceContext();
     Iterator<String> iterator = context.getPrefixes();
     while (iterator.hasNext()) {
       String next = iterator.next();
       String namespace = context.getNamespaceURI(next);
       if (namespaceURI.equals(namespace)) {
         String prefixName = attr.getLocalName();
         // put prefix corresponding found namespace into map for changing it further
         if (!prefixName.equals(next)) {
           prefixMap.put(prefixName, next);
         }
         // remove namespace delcaration.
         ((BpelEntityImpl) entity)
             .setAttribute(attr.getName(), new PrefixAttribute(attr.getName()), null);
       }
     }
   }
 }
 protected void validateTranslatableString(Element element, Attr attr, boolean shouldTranslate) {
   if (!shouldTranslate) return;
   int severity = CompilerFlags.getFlag(fProject, CompilerFlags.P_NOT_EXTERNALIZED);
   if (severity == CompilerFlags.IGNORE) return;
   String value = attr.getValue();
   if (!value.startsWith("%")) { // $NON-NLS-1$
     report(
         NLS.bind(MDECoreMessages.Builders_Manifest_non_ext_attribute, attr.getName()),
         getLine(element, attr.getName()),
         severity,
         MDEMarkerFactory.P_UNTRANSLATED_NODE,
         element,
         attr.getName(),
         MDEMarkerFactory.CAT_NLS);
   } else if (fModel instanceof AbstractNLModel) {
     NLResourceHelper helper = ((AbstractNLModel) fModel).getNLResourceHelper();
     if (helper == null || !helper.resourceExists(value)) {
       report(
           NLS.bind(MDECoreMessages.Builders_Manifest_key_not_found, value.substring(1)),
           getLine(element, attr.getName()),
           severity,
           MDEMarkerFactory.CAT_NLS);
     }
   }
 }
 protected void validateResourceAttribute(Element element, Attr attr) {
   int severity = CompilerFlags.getFlag(fProject, CompilerFlags.P_UNKNOWN_RESOURCE);
   if (severity != CompilerFlags.IGNORE && !resourceExists(attr.getValue())) {
     report(
         NLS.bind(
             MDECoreMessages.Builders_Manifest_resource,
             (new String[] {attr.getValue(), attr.getName()})),
         getLine(element, attr.getName()),
         severity,
         MDEMarkerFactory.CAT_OTHER);
   }
 }
  /**
   * Float the xml:* attributes of the unselected parent nodes to the ciurrent node.
   *
   * @param E
   * @param result
   */
  private void addXmlAttributes(Element E, SortedSet result) {
    /* The processing of an element node E MUST be modified slightly when an
     * XPath node-set is given as input and the element's parent is omitted
     * from the node-set. The method for processing the attribute axis of an
     * element E in the node-set is enhanced. All element nodes along E's
     * ancestor axis are examined for nearest occurrences of attributes in
     * the xml namespace, such as xml:lang and xml:space (whether or not they
     * are in the node-set). From this list of attributes, remove any that are
     * in E's attribute axis (whether or not they are in the node-set). Then,
     * lexicographically merge this attribute list with the nodes of E's
     * attribute axis that are in the node-set. The result of visiting the
     * attribute axis is computed by processing the attribute nodes in this
     * merged attribute list.
     */

    // E is in the node-set
    Node parent = E.getParentNode();
    Map loa = new HashMap();

    if ((parent != null) && (parent.getNodeType() == Node.ELEMENT_NODE) && !isVisible(parent)) {

      // parent element is not in node set
      for (Node ancestor = parent;
          (ancestor != null) && (ancestor.getNodeType() == Node.ELEMENT_NODE);
          ancestor = ancestor.getParentNode()) {
        Element el = ((Element) ancestor);
        if (!el.hasAttributes()) {
          continue;
        }
        // for all ancestor elements
        NamedNodeMap ancestorAttrs = el.getAttributes();

        for (int i = 0; i < ancestorAttrs.getLength(); i++) {

          // for all attributes in the ancestor element
          Attr currentAncestorAttr = (Attr) ancestorAttrs.item(i);

          if (XML_LANG_URI.equals(currentAncestorAttr.getNamespaceURI())) {

            // do we have an xml:* ?
            if (!E.hasAttributeNS(XML_LANG_URI, currentAncestorAttr.getLocalName())) {

              // the xml:* attr is not in E
              if (!loa.containsKey(currentAncestorAttr.getName())) {
                loa.put(currentAncestorAttr.getName(), currentAncestorAttr);
              }
            }
          }
        }
      }
    }
    result.addAll(loa.values());
  }
Beispiel #6
0
  private static SimpleXMLElement buildNode(
      Env env,
      QuercusClass cls,
      SimpleXMLElement parent,
      Node node,
      String namespace,
      boolean isPrefix) {
    if (node.getNodeType() == Node.TEXT_NODE) {
      String value = node.getNodeValue();

      if (parent != null) {
        parent.addChild(new SimpleXMLText(env, cls, env.createString(value)));

        if (!isWhitespace(value)) parent.addText(env.createString(value));
      }

      return parent;
    }

    /*
    NamedNodeMap attrMap = node.getAttributes();
    Node namespaceAttr = attrMap.getNamedItem("xmlns");

    if (namespaceAttr != null)
      namespace = namespaceAttr.getNodeValue();
    */

    SimpleXMLElement elt = new SimpleXMLElement(env, cls, parent, node.getNodeName(), namespace);

    if (parent != null) parent.addChild(elt);

    NamedNodeMap attrs = node.getAttributes();

    if (attrs != null) {
      int length = attrs.getLength();

      for (int i = 0; i < length; i++) {
        Attr attr = (Attr) attrs.item(i);

        if (attr.getName().startsWith("xmlns")) {
          elt.addNamespaceAttribute(env, attr.getName(), attr.getValue());
        } else {
          elt.addAttribute(env, attr.getName(), env.createString(attr.getValue()), namespace);
        }
      }
    }

    for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
      buildNode(env, cls, elt, child, namespace, isPrefix);
    }

    return elt;
  }
Beispiel #7
0
  private void processNode(org.w3c.dom.Node node, com.dragonflow.XmlApi.XmlApiObject xmlapiobject) {
    if (node.getNodeType() == 1) {
      String s = node.getNodeName();
      if (s != null && s.length() > 0) {
        jgl.HashMap hashmap = new HashMap();
        org.w3c.dom.NamedNodeMap namednodemap = node.getAttributes();
        for (int i = 0; i < namednodemap.getLength(); i++) {
          org.w3c.dom.Attr attr = (org.w3c.dom.Attr) namednodemap.item(i);
          if (attr.getName() != null
              && attr.getName().equals("encodeValues")
              && attr.getValue() != null
              && (attr.getValue().equals("false") || attr.getValue().equals("true"))) {
            encodeValues = (new Boolean(attr.getValue())).booleanValue();
            continue;
          }
          String s1 = attr.getValue();
          if (s1 != null) {
            s1 = com.dragonflow.Utils.TextUtils.enlighten(s1);
          }
          hashmap.put(attr.getName(), s1);
        }

        org.w3c.dom.NodeList nodelist = node.getChildNodes();
        java.util.Vector vector = findPropNodes(nodelist);
        for (int j = 0; j < vector.size(); j++) {
          org.w3c.dom.Node node1 = (org.w3c.dom.Node) vector.elementAt(j);
          org.w3c.dom.NodeList nodelist1 = node1.getChildNodes();
          String s2 = findPropertyName(nodelist1);
          String as[] = findValueNodes(nodelist1);
          if (as.length > 1) {
            hashmap.put(s2, as);
            continue;
          }
          if (as.length == 1) {
            hashmap.put(s2, as[0]);
          } else {
            hashmap.put(s2, "");
          }
        }

        xmlapiobject.setProperties(hashmap);
        xmlapiobject.setName(s);
        java.util.Vector vector1 = findChildrenNodes(nodelist);
        for (int k = 0; k < vector1.size(); k++) {
          org.w3c.dom.Node node2 = (org.w3c.dom.Node) vector1.elementAt(k);
          processNode(node2, xmlapiobject.add());
        }
      }
    }
  }
Beispiel #8
0
 private Attributes copyAttributes(Element node) {
   AttributesImpl attrs = new AttributesImpl();
   NamedNodeMap nnm = node.getAttributes();
   for (int count = 0; count < nnm.getLength(); count++) {
     Attr attr = (Attr) nnm.item(count);
     String name = attr.getName();
     if (name.startsWith("xmlns:") || name.equals("xmlns")) {
       // Skip it; (don't ya just love it!!)
     } else {
       attrs.addAttribute(
           attr.getNamespaceURI(), attr.getName(), attr.getName(), "CDATA", attr.getValue());
     }
   }
   return attrs;
 }
Beispiel #9
0
 @Override
 public void init(Element element) {
   final Element settingsElement = (Element) element.getElementsByTagName("settings").item(0);
   final NamedNodeMap attributes = settingsElement.getAttributes();
   for (int i = 0; i < attributes.getLength(); i++) {
     final Node node = attributes.item(i);
     if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
       final Attr attr = (Attr) node;
       this.params.put(attr.getName(), Float.parseFloat(attr.getValue()));
     }
   }
   final float top = this.params.get("top");
   final float left = this.params.get("left");
   final float bottom = this.params.get("bottom");
   final float right = this.params.get("right");
   final float bWidth = this.params.get("blockWidth");
   final float bHeight = this.params.get("blockHeight");
   final List<XYZItem> truc = new LinkedList<XYZItem>();
   for (float x = left; x < right; x += bWidth) {
     for (float y = bottom; y < top; y += bHeight) {
       truc.add(new XYZItem(x, y, getZValue(x, y)));
     }
   }
   this.map = new double[3][truc.size()];
   int i = 0;
   for (XYZItem item : truc) {
     this.map[0][i] = item.getXValue();
     this.map[1][i] = item.getYValue();
     this.map[2][i] = item.getZValue();
     i++;
   }
 }
Beispiel #10
0
 private void createAndCacheNamespaces(Ruby ruby, Node node) {
   if (node == null) return;
   if (node.hasAttributes()) {
     NamedNodeMap nodeMap = node.getAttributes();
     for (int i = 0; i < nodeMap.getLength(); i++) {
       Node n = nodeMap.item(i);
       if (n instanceof Attr) {
         Attr attr = (Attr) n;
         String attrName = attr.getName();
         // not sure, but need to get value always before document is referred.
         // or lose attribute value
         String attrValue = attr.getValue();
         if (isNamespace(attrName)) {
           String prefix = getLocalNameForNamespace(attrName);
           prefix = prefix != null ? prefix : "";
           nsCache.put(ruby, prefix, attrValue, node, this);
         }
       }
     }
   }
   NodeList children = node.getChildNodes();
   for (int i = 0; i < children.getLength(); i++) {
     createAndCacheNamespaces(ruby, children.item(i));
   }
 }
 public String getName() {
   String result = null;
   switch (kind) {
     case KIND_ATTR_TEXT:
       {
         result = "value";
         break;
       }
     case KIND_ELEMENT_ATTR:
       {
         result = attribute.getName();
         break;
       }
     case KIND_ELEMENT_CMATTRIBUTE:
       {
         CMAttributeDeclaration ad = (CMAttributeDeclaration) cmNode;
         result = ad.getNodeName();
         break;
       }
     case KIND_ELEMENT_TEXT:
       {
         result = "text value";
         break;
       }
   }
   return result != null ? result : "";
 }
Beispiel #12
0
  // Walk the tree from a specified element,
  // inserting data from a DicomObject where required.
  private static String getElementText(Element element, DicomObject dicomObject) {

    if (dicomTag(element)) return getDicomElementText(element, dicomObject);

    if (element.getTagName().equals("block")) return getBlockText(element, dicomObject);

    StringBuffer sb = new StringBuffer();
    sb.append("<" + element.getTagName());
    NamedNodeMap attributes = element.getAttributes();
    Attr attr;
    for (int i = 0; i < attributes.getLength(); i++) {
      attr = (Attr) attributes.item(i);
      String attrValue = attr.getValue().trim();
      if (dicomTag(attrValue)) {
        attrValue = getDicomElementText(attrValue, dicomObject);
      }
      sb.append(" " + attr.getName() + "=\"" + attrValue + "\"");
    }
    sb.append(">");
    if (element.getTagName().equals("table")) sb.append(getTableText(element, dicomObject));
    else if (element.getTagName().equals("publication-date")) sb.append(StringUtil.getDate());
    else sb.append(getChildrenText(element, dicomObject));
    sb.append("</" + element.getTagName() + ">");
    return sb.toString();
  }
Beispiel #13
0
    Shuttle(Shuttle cp, Element e) {
      this.node = e;
      this.g = cp.g;
      this.svgRoot = cp.svgRoot;
      this.shape = cp.shape;
      this.clip = cp.clip;
      this.fontSize = cp.fontSize;
      this.fontFamily = cp.fontFamily;
      this.stroke = cp.stroke;
      this.fill = cp.fill;
      this.strokeWidth = cp.strokeWidth;
      this.transform = new AffineTransform(cp.transform);
      this.opacity = cp.opacity;
      if (e.hasAttributes()) {
        NamedNodeMap atts = e.getAttributes();
        for (int i = 0; i < atts.getLength(); ++i) {

          Attr att = Attr.class.cast(atts.item(i));
          if (att.getNamespaceURI() != null) continue;
          String s = att.getName();
          String value = att.getValue();
          if (s.equals("style")) {
            for (String styles : value.split("[;]+")) {
              int j = styles.indexOf(':');
              if (j != -1) {
                applyStyle(styles.substring(0, j).trim(), styles.substring(j + 1).trim());
              }
            }

          } else {
            applyStyle(s, att.getValue());
          }
        }
      }
    }
 public String generateAttrName(Attr attr) {
   if (attr == null) return null;
   String attrName = attr.getName();
   if (attrName == null) return null;
   if (attrName.startsWith(JSPTag.TAG_OPEN)) {
     if (!attrName.endsWith(JSPTag.TAG_CLOSE)) {
       // close JSP
       return (attrName + JSPTag.TAG_CLOSE);
     }
   }
   if (((IDOMAttr) attr).isGlobalAttr() && CMNodeUtil.getAttributeDeclaration(attr) != null) {
     switch (getAttrNameCase(attr)) {
       case DocumentTypeAdapter.UPPER_CASE:
         attrName = attrName.toUpperCase(Locale.ENGLISH);
         break;
       case DocumentTypeAdapter.LOWER_CASE:
         attrName = attrName.toLowerCase(Locale.ENGLISH);
         break;
       default:
         // ASIS_CASE
         break;
     }
   }
   return attrName;
 }
Beispiel #15
0
 private void moveNSDeclarationToRoot(BpelEntity entity, Map<String, String> prefixMap) {
   if (!(entity instanceof BpelEntityImpl)) {
     return;
   }
   Element element = ((BpelEntityImpl) entity).getPeer();
   NamedNodeMap map = element.getAttributes();
   for (int i = 0; i < map.getLength(); i++) {
     Node node = map.item(i);
     assert node instanceof Attr;
     Attr attr = (Attr) node;
     if (attr.getValue() == null) {
       continue;
     }
     try {
       if (XMLNS.equals(attr.getName()) || (XMLNS.equals(attr.getPrefix()))) {
         SingletonMap pMap = moveNsDeclaration(entity, attr);
         if (!pMap.keyEqualsValue()) {
           prefixMap.put(pMap.getKey(), pMap.getValue());
         }
       }
     } catch (InvalidNamespaceException e) {
       // This is the case
       // when namespace was originally incorrect and we do not move it
       // to root. We don't do anything.
     }
   }
   /*
    *  we need to update prefixes for those declarations that changed
    *  its perfix after lifing up decl.
    */
   updatePrefixes(entity, prefixMap);
   for (BpelEntity child : entity.getChildren()) {
     moveNSDeclarationToRoot(child, prefixMap);
   }
 }
Beispiel #16
0
  /**
   * Copy in-scope namespace declarations of the decl node to the decl node itself so that this move
   * won't change the in-scope namespace bindings.
   */
  private void copyInscopeNSAttributes(Element e) {
    Element p = e;
    Set<String> inscopes = new HashSet<String>();
    while (true) {
      NamedNodeMap atts = p.getAttributes();
      for (int i = 0; i < atts.getLength(); i++) {
        Attr a = (Attr) atts.item(i);
        if (Constants.NS_XMLNS.equals(a.getNamespaceURI())) {
          String prefix;
          if (a.getName().indexOf(':') == -1) prefix = "";
          else prefix = a.getLocalName();

          if (inscopes.add(prefix) && p != e) {
            // if this is the first time we see this namespace bindings,
            // copy the declaration.
            // if p==decl, there's no need to. Note that
            // we want to add prefix to inscopes even if p==Decl

            e.setAttributeNodeNS((Attr) a.cloneNode(true));
          }
        }
      }

      if (p.getParentNode() instanceof Document) break;

      p = (Element) p.getParentNode();
    }

    if (!inscopes.contains("")) {
      // if the default namespace was undeclared in the context of decl,
      // it must be explicitly set to "" since the new environment might
      // have a different default namespace URI.
      e.setAttributeNS(Constants.NS_XMLNS, "xmlns", "");
    }
  }
 /**
  * Validates that the version of the given plug-in is available in the registry. Adds a warning if
  * the plug-in could not be found.
  *
  * @param plugin xml element describing the plug-in to look for in the registry
  * @param attr set of element attributes
  */
 private void validateVersion(Element plugin, Attr attr) {
   String id = plugin.getAttribute("id"); // $NON-NLS-1$
   String version = plugin.getAttribute("version"); // $NON-NLS-1$
   if (id.trim().length() == 0
       || version.trim().length() == 0
       || version.equals("0.0.0")) // $NON-NLS-1$
   return;
   ModelEntry entry = PluginRegistry.findEntry(id);
   if (entry != null) {
     IPluginModelBase[] allModels = entry.getActiveModels();
     for (int i = 0; i < allModels.length; i++) {
       IPluginModelBase availablePlugin = allModels[i];
       if (id.equals(availablePlugin.getPluginBase().getId())) {
         if (version.equals(availablePlugin.getPluginBase().getVersion())) {
           return;
         }
       }
     }
   }
   report(
       NLS.bind(
           PDECoreMessages.Builders_Feature_mismatchPluginVersion, new String[] {version, id}),
       getLine(plugin, attr.getName()),
       CompilerFlags.WARNING,
       PDEMarkerFactory.CAT_OTHER);
 }
 /** @param element */
 private void validatePlugins(Element parent) {
   NodeList list = getChildrenByName(parent, "plugin"); // $NON-NLS-1$
   for (int i = 0; i < list.getLength(); i++) {
     if (fMonitor.isCanceled()) return;
     Element plugin = (Element) list.item(i);
     assertAttributeDefined(plugin, "id", CompilerFlags.ERROR); // $NON-NLS-1$
     assertAttributeDefined(plugin, "version", CompilerFlags.ERROR); // $NON-NLS-1$
     NamedNodeMap attributes = plugin.getAttributes();
     boolean isFragment =
         plugin.getAttribute("fragment").equals("true"); // $NON-NLS-1$ //$NON-NLS-2$
     for (int j = 0; j < attributes.getLength(); j++) {
       Attr attr = (Attr) attributes.item(j);
       String name = attr.getName();
       if (name.equals("id")) { // $NON-NLS-1$
         validatePluginID(plugin, attr, isFragment);
       } else if (name.equals("version")) { // $NON-NLS-1$
         validateVersionAttribute(plugin, attr);
         validateVersion(plugin, attr);
       } else if (name.equals("fragment") || name.equals("unpack")) { // $NON-NLS-1$ //$NON-NLS-2$
         validateBoolean(plugin, attr);
       } else if (!name.equals("os")
           && !name.equals("ws")
           && !name.equals("nl") // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
           && !name.equals("arch")
           && !name.equals("download-size") // $NON-NLS-1$ //$NON-NLS-2$
           && !name.equals("install-size")
           && !name.equals("filter")) { // $NON-NLS-1$ //$NON-NLS-2$
         reportUnknownAttribute(plugin, name, CompilerFlags.ERROR);
       }
     }
     validateUnpack(plugin);
   }
 }
Beispiel #19
0
  public Attr setAttributeNode(Attr newAttr) throws DOMException {
    // Check if this attribute is already in use.
    Element owner = newAttr.getOwnerElement();
    if (owner != null) {
      if (owner == this) { // Replacing an attribute node by itself has no effect
        return null;
      } else {
        throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR, Messages.getString("imageio.8E"));
      }
    }

    String name = newAttr.getName();
    Attr oldAttr = getAttributeNode(name);
    if (oldAttr != null) {
      removeAttributeNode(oldAttr);
    }

    IIOMetadataAttr iioAttr;
    if (newAttr instanceof IIOMetadataAttr) {
      iioAttr = (IIOMetadataAttr) newAttr;
      iioAttr.setOwnerElement(this);
    } else {
      iioAttr = new IIOMetadataAttr(name, newAttr.getValue(), this);
    }

    attrs.list.add(iioAttr);

    return oldAttr;
  }
 @Override
 public Directive getAngularDirective(Object project, Attr attr) {
   if (attr == null) {
     return null;
   }
   return AngularModulesManager.getInstance()
       .getDirective(project, attr.getOwnerElement().getNodeName(), attr.getName(), Restriction.A);
 }
Beispiel #21
0
 private static void showNode(Node node, int depth) throws SAXException {
   // ystem.out.println(node.getNodeType());
   NodeList children;
   switch (node.getNodeType()) {
     case Node.ATTRIBUTE_NODE:
       printTab(depth);
       Attr attr = (Attr) node;
       System.out.println(attr.getName() + ":" + attr.getValue());
       break;
     case Node.ELEMENT_NODE:
       printTab(depth);
       System.out.print("<" + node.getNodeName() + ">");
       children = node.getChildNodes();
       if (children.getLength() == 1 && children.item(0).getNodeType() == Node.TEXT_NODE) {
         System.out.println(children.item(0).getNodeValue());
       } else {
         System.out.println();
       }
       NamedNodeMap attributes = node.getAttributes();
       for (int i = 0; i < attributes.getLength(); i++) {
         showNode(attributes.item(i), depth + 1);
       }
       if (children.getLength() != 1 || children.item(0).getNodeType() != Node.TEXT_NODE) {
         for (int i = 0; i < children.getLength(); i++) {
           showNode(children.item(i), depth + 1);
         }
       }
       break;
     case Node.TEXT_NODE:
       String text = node.getNodeValue();
       if (!text.trim().isEmpty()) {
         printTab(depth);
         System.out.print(node);
         System.out.print(":");
         System.out.print(text);
         System.out.println(":");
       }
       break;
     case Node.CDATA_SECTION_NODE:
     case Node.COMMENT_NODE:
     case Node.PROCESSING_INSTRUCTION_NODE:
     case Node.DOCUMENT_FRAGMENT_NODE:
     case Node.DOCUMENT_NODE:
     case Node.DOCUMENT_TYPE_NODE:
     case Node.ENTITY_NODE:
     case Node.ENTITY_REFERENCE_NODE:
     case Node.NOTATION_NODE:
       printTab(depth);
       System.out.println(node);
       children = node.getChildNodes();
       for (int i = 0; i < children.getLength(); i++) {
         showNode(children.item(i), depth + 1);
       }
       break;
     default:
       throw new SAXException("Unexpected node type: " + node.getNodeType() + " in showNode");
   }
 }
 private void validateImports(Element parent) {
   NodeList list = getChildrenByName(parent, "import"); // $NON-NLS-1$
   for (int i = 0; i < list.getLength(); i++) {
     if (fMonitor.isCanceled()) return;
     Element element = (Element) list.item(i);
     Attr plugin = element.getAttributeNode("plugin"); // $NON-NLS-1$
     Attr feature = element.getAttributeNode("feature"); // $NON-NLS-1$
     if (plugin == null && feature == null) {
       assertAttributeDefined(element, "plugin", CompilerFlags.ERROR); // $NON-NLS-1$
     } else if (plugin != null && feature != null) {
       reportExclusiveAttributes(
           element, "plugin", "feature", CompilerFlags.ERROR); // $NON-NLS-1$//$NON-NLS-2$
     } else if (plugin != null) {
       validatePluginID(element, plugin, false);
     } else if (feature != null) {
       validateFeatureID(element, feature);
     }
     NamedNodeMap attributes = element.getAttributes();
     for (int j = 0; j < attributes.getLength(); j++) {
       Attr attr = (Attr) attributes.item(j);
       String name = attr.getName();
       if (name.equals("version")) { // $NON-NLS-1$
         validateVersionAttribute(element, attr);
       } else if (name.equals("match")) { // $NON-NLS-1$
         if (element.getAttributeNode("patch") != null) { // $NON-NLS-1$
           report(
               NLS.bind(PDECoreMessages.Builders_Feature_patchedMatch, attr.getValue()),
               getLine(element, attr.getValue()),
               CompilerFlags.ERROR,
               PDEMarkerFactory.CAT_FATAL);
         } else {
           validateMatch(element, attr);
         }
       } else if (name.equals("patch")) { // $NON-NLS-1$
         if ("true".equalsIgnoreCase(attr.getValue()) && feature == null) { // $NON-NLS-1$
           report(
               NLS.bind(PDECoreMessages.Builders_Feature_patchPlugin, attr.getValue()),
               getLine(element, attr.getValue()),
               CompilerFlags.ERROR,
               PDEMarkerFactory.CAT_FATAL);
         } else if ("true".equalsIgnoreCase(attr.getValue())
             && element.getAttributeNode("version") == null) { // $NON-NLS-1$ //$NON-NLS-2$
           report(
               NLS.bind(PDECoreMessages.Builders_Feature_patchedVersion, attr.getValue()),
               getLine(element, attr.getValue()),
               CompilerFlags.ERROR,
               PDEMarkerFactory.CAT_FATAL);
         } else {
           validateBoolean(element, attr);
         }
       } else if (!name.equals("plugin")
           && !name.equals("feature")
           && !name.equals("filter")) { // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         reportUnknownAttribute(element, name, CompilerFlags.ERROR);
       }
     }
   }
 }
Beispiel #23
0
 private XedCursor findChildAttr(
     final Attr attr, final XedCursor cursorParent, final XedCursor cursorType) {
   final Xed xed = cursorParent.getXed();
   final Element elementParent = cursorParent.getElement();
   final TypeInstance typeInstance = cursorType.getTypeInstance();
   final Attr attrIt =
       (elementParent == null) ? null : ElementU.getAttributeNode(elementParent, attr.getName());
   return ((attrIt == null) ? null : new XedCursor(xed, cursorType, attrIt, 0, typeInstance));
 }
 public static NutMap toAttrMap(NamedNodeMap attrs) {
   NutMap map = new NutMap();
   int len = attrs.getLength();
   for (int j = 0; j < len; j++) {
     Attr attr = (Attr) attrs.item(j);
     map.put(attr.getName(), attr.getValue());
   }
   return map;
 }
 public CMAttributeDeclaration getCMAttributeDeclaration(Attr attr) {
   CMAttributeDeclaration result = null;
   Element element = attr.getOwnerElement();
   if (element != null) {
     CMElementDeclaration ed = getCMElementDeclaration(element);
     if (ed != null) {
       result = (CMAttributeDeclaration) ed.getAttributes().getNamedItem(attr.getName());
       if (result == null) {
         // try to get the unprefixed name
         String name = DOMNamespaceHelper.getUnprefixedName(attr.getName());
         result = (CMAttributeDeclaration) ed.getAttributes().getNamedItem(name);
       }
       if (result == null) {
         // todo... perhaps this is a globally defined attribute...
       }
     }
   }
   return result;
 }
 private void validateExistingExtensionAttributes(
     Element element, NamedNodeMap attrs, ISchemaElement schemaElement) {
   for (int i = 0; i < attrs.getLength(); i++) {
     Attr attr = (Attr) attrs.item(i);
     ISchemaAttribute attInfo = schemaElement.getAttribute(attr.getName());
     if (attInfo == null) {
       HashSet allowedElements = new HashSet();
       computeAllowedElements(schemaElement.getType(), allowedElements);
       if (allowedElements.contains(attr.getName())) {
         validateJavaAttribute(element, attr);
       } else {
         int flag = CompilerFlags.getFlag(fProject, CompilerFlags.P_UNKNOWN_ATTRIBUTE);
         if (flag != CompilerFlags.IGNORE) reportUnknownAttribute(element, attr.getName(), flag);
       }
     } else {
       validateExtensionAttribute(element, attr, attInfo);
     }
   }
 }
 public String generateAttrValue(Attr attr, char quote) {
   if (attr == null) return null;
   String name = attr.getName();
   SourceValidator validator = new SourceValidator(attr);
   String value = validator.convertSource(((IDOMNode) attr).getValueSource());
   if (value == null || value.length() == 0) {
     if (name != null && name.startsWith(JSPTag.TAG_OPEN)) return null;
     if (isBooleanAttr(attr)) {
       if (((AttrImpl) attr).isXMLAttr()) {
         // generate the name as value
         value = attr.getName();
       } else {
         // not to generate '=' and value for HTML boolean
         return null;
       }
     }
   }
   return generateAttrValue(value, quote);
 }
 protected static int countNonNamespaceAttribures(NamedNodeMap attrs) {
   int n = 0;
   for (int i = 0; i < attrs.getLength(); i++) {
     Attr attr = (Attr) attrs.item(i);
     if (!attr.getName().startsWith("xmlns")) {
       n++;
     }
   }
   return n;
 }
 /**
  * Setup the ID attribute into <code>destElement</code> depending on the <code>isId</code> flag of
  * an attribute of <code>sourceNode</code>.
  *
  * @param sourceNode
  * @param destDocElement
  */
 public static void propagateIDAttributeSetup(Node sourceNode, Element destElement) {
   NamedNodeMap nnm = sourceNode.getAttributes();
   for (int i = 0; i < nnm.getLength(); i++) {
     Attr attr = (Attr) nnm.item(i);
     if (attr.isId()) {
       destElement.setIdAttribute(attr.getName(), true);
       break;
     }
   }
 }
 @Override
 public DirectiveParameter getAngularDirectiveParameter(Object project, Attr attr) {
   Element element = attr.getOwnerElement();
   // check if owner element is a directive?
   Directive elementDirective = getAngularDirective(project, element);
   if (elementDirective != null) {
     return elementDirective.getParameter(attr.getName());
   } else {
     // retrieve directives from other attributes.
     List<Directive> directives = getAngularDirectives(project, attr.getOwnerElement(), attr);
     DirectiveParameter parameter = null;
     for (Directive directive : directives) {
       parameter = directive.getParameter(attr.getName());
       if (parameter != null) {
         return parameter;
       }
     }
   }
   return null;
 }