Examples of CMAttributeDeclaration


Examples of org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration

        IDOMAttr xmlattr = (IDOMAttr) a;
        if (!xmlattr.isGlobalAttr())
          continue; // skip futher validation and begin next loop.
      }

      CMAttributeDeclaration adec = (CMAttributeDeclaration) declarations.getNamedItem(a.getName());
      final String attrName = a.getName().toLowerCase(Locale.US);
      /* Check the modelquery if nothing is declared by the element declaration */
      if (adec == null) {
        if (modelQueryNodes == null)
          modelQueryNodes = ModelQueryUtil.getModelQuery(target.getOwnerDocument()).getAvailableContent((Element) node, edec, ModelQuery.INCLUDE_ATTRIBUTES);
       
       
        for (int k = 0; k < modelQueryNodes.size(); k++) {
          CMNode cmnode = (CMNode) modelQueryNodes.get(k);
          if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION && cmnode.getNodeName().toLowerCase(Locale.US).equals(attrName)) {
            adec = (CMAttributeDeclaration) cmnode;
            break;
          }
        }
      }
     
      if (adec == null) {
        if ((attrName.startsWith(ATTR_NAME_DATA) && attrName.length() > ATTR_NAME_DATA_LENGTH) || (attrName.startsWith(ATTR_NAME_USER_AGENT_FEATURE) && attrName.length() > ATTR_NAME_USER_AGENT_FEATURE_LENGTH))
          continue;
        // No attr declaration was found. That is, the attr name is
        // undefined.
        // but not regard it as undefined name if it includes nested
        // region
        if (!hasNestedRegion(((IDOMNode) a).getNameRegion())) {
          rgnType = REGION_NAME;
          state = ErrorState.UNDEFINED_NAME_ERROR;
        }
      } else {
        // The attr declaration was found.
        // At 1st, the name should be checked.
        if (CMUtil.isObsolete(adec)){
          state = ErrorState.OBSOLETE_ATTR_NAME_ERROR;
        }
        if (CMUtil.isHTML(edec) && (!CMUtil.isXHTML(edec))) {
          // If the target element is pure HTML (not XHTML), some
          // attributes
          // might be written in boolean format. It should be check
          // specifically.
          if (CMUtil.isBooleanAttr(adec) && ((IDOMAttr) a).hasNameOnly())
            continue; // OK, keep going. No more check is needed
          // against this attr.
        } else {
          // If the target is other than pure HTML (JSP or XHTML),
          // the name
          // must be checked exactly (ie in case sensitive way).
          String actual = a.getName();
          String desired = adec.getAttrName();
          if (!actual.equals(desired)) { // case mismatch
            rgnType = REGION_NAME;
            state = ErrorState.MISMATCHED_ERROR;
          }
        }
        // Then, the value must be checked.
        if (state == ErrorState.NONE_ERROR) { // Need more check.
          // Now, the value should be checked, if the type is ENUM.
          CMDataType attrType = adec.getAttrType();
          if (a instanceof IDOMAttr) {
            final ITextRegion region = ((IDOMAttr) a).getEqualRegion();
            if (region == null) {
              rgnType = REGION_NAME;
              state = ErrorState.MISSING_ATTR_VALUE_EQUALS_ERROR;
View Full Code Here

Examples of org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration

  private boolean isUnknownAttr(IDOMAttr attr, Element target) {
    CMElementDeclaration dec = CMUtil.getDeclaration(target);
    if (dec == null)
      return true; // unknown.
    CMNamedNodeMap adecls = dec.getAttributes();
    CMAttributeDeclaration adec = (CMAttributeDeclaration) adecls.getNamedItem(attr.getName());
    return adec == null;
  }
View Full Code Here

Examples of org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration

        else if ((nodeName.equals(JSP11TLDNames.INFO) || nodeName.equals(JSP12TLDNames.DESCRIPTION)) && child.hasChildNodes()) {
          ed.setDescription(getContainedText(child));
        }
        // attributes
        else if (nodeName.equals(JSP11TLDNames.ATTRIBUTE)) {
          CMAttributeDeclaration attr = createAttributeDeclaration(document, child);
          ed.fAttributes.setNamedItem(attr.getAttrName(), attr);
        }
        // variables
        else if (nodeName.equals(JSP12TLDNames.VARIABLE)) {
          ed.getVariables().add(createVariable(child));
        }
View Full Code Here

Examples of org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration

            lastRegion = startStructuredDocumentRegion.getRegionAtCharacterOffset(index - 1);
          }
          MultiTextEdit multiTextEdit = new MultiTextEdit();
          try {
            for (int i = insertAttrs.size() - 1; i >= 0; i--) {
              CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) insertAttrs.get(i);
              String requiredAttributeName = attrDecl.getAttrName();
              String defaultValue = attrDecl.getDefaultValue();
              if (defaultValue == null)
                defaultValue = ""; //$NON-NLS-1$
              String nameAndDefaultValue = " "; //$NON-NLS-1$
              if (i == 0 && lastRegion.getLength() > lastRegion.getTextLength())
                nameAndDefaultValue = ""; //$NON-NLS-1$
View Full Code Here

Examples of org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration

    if (modelQuery != null) {
      CMElementDeclaration elementDecl = modelQuery.getCMElementDeclaration((Element) node);
      if (elementDecl != null) {
        CMNamedNodeMap attrMap = elementDecl.getAttributes();
        Iterator it = attrMap.iterator();
        CMAttributeDeclaration attr = null;
        while (it.hasNext()) {
          attr = (CMAttributeDeclaration) it.next();
          if (attr.getUsage() == CMAttributeDeclaration.REQUIRED) {
            result.add(attr);
          }
        }
      }
    }
View Full Code Here

Examples of org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration

    return false;
  }

  private void checkRequiredAttributes(IDOMElement element, CMNamedNodeMap attrMap, IReporter reporter, IFile file, IStructuredDocument document, IStructuredDocumentRegion documentRegion) {
    Iterator it = attrMap.iterator();
    CMAttributeDeclaration attr = null;
    while (it.hasNext()) {
      attr = (CMAttributeDeclaration) it.next();
      if (attr.getUsage() == CMAttributeDeclaration.REQUIRED) {
        Attr a = element.getAttributeNode(attr.getAttrName());
        if (a == null) {
          // Attribute may be defined using a jsp:attribute action
          if (!checkJSPAttributeAction(element, attr)) {
            String msgText = NLS.bind(JSPCoreMessages.JSPDirectiveValidator_5, attr.getAttrName());
            LocalizedMessage message = new LocalizedMessage(fSeverityMissingRequiredAttribute, msgText, file);
            int start = element.getStartOffset();
            int length = element.getStartEndOffset() - start;
            int lineNo = document.getLineOfOffset(start);
            message.setLineNo(lineNo);
View Full Code Here

Examples of org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration

    }

    NamedNodeMap attrs = element.getAttributes();
    for (int i = 0; i < attrs.getLength(); i++) {
      Attr a = (Attr) attrs.item(i);
      CMAttributeDeclaration adec = (CMAttributeDeclaration) cmAttrs.getNamedItem(a.getName());
      if (adec == null) {
        /*
         * No attr declaration was found. That is, the attr name is
         * undefined. Disregard it includes JSP structure or this
         * element supports dynamic attributes
View Full Code Here

Examples of org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration

    if (modelQuery != null) {
      CMElementDeclaration elementDecl = modelQuery.getCMElementDeclaration((Element) node);
      if (elementDecl != null) {
        CMNamedNodeMap attrMap = elementDecl.getAttributes();
        Iterator it = attrMap.iterator();
        CMAttributeDeclaration attr = null;
        while (it.hasNext()) {
          attr = (CMAttributeDeclaration) it.next();
          if (attr.getUsage() == CMAttributeDeclaration.REQUIRED) {
            result.add(attr);
          }
        }
      }
    }
View Full Code Here

Examples of org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration

            lastRegion = startStructuredDocumentRegion.getRegionAtCharacterOffset(index - 1);
          }
          MultiTextEdit multiTextEdit = new MultiTextEdit();
          try {
            for (int i = insertAttrs.size() - 1; i >= 0; i--) {
              CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) insertAttrs.get(i);
              String requiredAttributeName = attrDecl.getAttrName();
              String defaultValue = attrDecl.getDefaultValue();
              if (defaultValue == null)
                defaultValue = ""; //$NON-NLS-1$
              String nameAndDefaultValue = " "; //$NON-NLS-1$
              if (i == 0 && lastRegion.getLength() > lastRegion.getTextLength())
                nameAndDefaultValue = ""; //$NON-NLS-1$
View Full Code Here

Examples of org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration

            formatContraints.setInPreserveSpaceElement(true);
          }
          else {
            CMNamedNodeMap cmAttributes = elementDeclaration.getAttributes();
            // Check implied values from the DTD way.
            CMAttributeDeclaration attributeDeclaration = (CMAttributeDeclaration) cmAttributes.getNamedItem(XML_SPACE);
            if (attributeDeclaration != null) {
              // CMAttributeDeclaration found, check it out.
              String defaultValue = attributeDeclaration.getAttrType().getImpliedValue();

              // xml:space="preserve" means preserve space,
              // everything else means back to default.
              if (PRESERVE.compareTo(defaultValue) == 0)
                formatContraints.setInPreserveSpaceElement(true);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.