Examples of CMNamedNodeMap


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

    }
    if (null == structModel) {
      return null;
    }
    CMElementDeclaration cmde = null;
    CMNamedNodeMap cmnnm = null;
    if (fNode == null || fNode.getNodeType() != Node.ELEMENT_NODE) {
      cmde = null;
    }
    ModelQuery modelQuery = ModelQueryUtil.getModelQuery(fNode
        .getOwnerDocument());
View Full Code Here

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

   * @param filter
   * @return list of attribute names
   */
  public static List getNameList(Element element, String[] filter) {
    List result = new ArrayList();
    CMNamedNodeMap attributes = getElementDeclaredAttributes(element);
    if (attributes != null) {
      for (int i = 0, n = attributes.getLength(); i < n; i++) {
        String name = attributes.item(i).getNodeName();
        if (Arrays.asList(filter).contains(name))
          result.add(name);
      }
    }
    return result;
View Full Code Here

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

    if (CMUtil.isForeign(target))
      return;
    CMElementDeclaration edec = CMUtil.getDeclaration(target);
    if (edec == null)
      return;
    CMNamedNodeMap declarations = edec.getAttributes();

    List modelQueryNodes = null;
    NamedNodeMap attrs = target.getAttributes();
    for (int i = 0; i < attrs.getLength(); i++) {
      int rgnType = REGION_NAME;
      int state = ErrorState.NONE_ERROR;
      Attr a = (Attr) attrs.item(i);
      // D203637; If the target attr has prefix, the validator should
      // not
      // warn about it. That is, just ignore. It is able to check
      // whether
      // an attr has prefix or not by calling XMLAttr#isGlobalAttr().
      // When a attr has prefix (not global), it returns false.
      boolean isXMLAttr = a instanceof IDOMAttr;
      if (isXMLAttr) {
        IDOMAttr xmlattr = (IDOMAttr) a;
        if (!xmlattr.isGlobalAttr())
          continue; // skip futher validation and begin next loop.
      }

      String attrName = a.getName().toLowerCase(Locale.US);
      if (attrName.startsWith(ATTR_NAME_DATA) && attrName.length() > ATTR_NAME_DATA.length())
        continue;

      CMAttributeDeclaration adec = (CMAttributeDeclaration) declarations.getNamedItem(a.getName());
     
      /* 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);
View Full Code Here

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

    buffer.append("\n\t listeners:"); //$NON-NLS-1$
    for (int i = 0; i < getListeners().size(); i++) {
      buffer.append("\n" + StringUtils.replace(getListeners().get(i).toString(), "\n", "\n\t\t")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    }
    buffer.append("\n\t elements:"); //$NON-NLS-1$
    CMNamedNodeMap elements = getElements();
    for (int i = 0; i < elements.getLength(); i++) {
      buffer.append(StringUtils.replace(elements.item(i).toString(), "\n", "\n\t\t")); //$NON-NLS-1$ //$NON-NLS-2$
    }
    return buffer.toString();
  }
View Full Code Here

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

    }
    CMDocument cm = modelQuery.getCorrespondingCMDocument(document);
    if (cm == null) {
      return null;
    }
    CMNamedNodeMap map = cm.getElements();
    if (map == null) {
      return null;
    }

    TagScanner scanner = new TagScanner(data, 1);
    String name = scanner.nextName();
    if (name == null) {
      return null;
    }
    StringBuffer buffer = new StringBuffer(name.length() + 4);
    buffer.append(SSI_PREFIX);
    buffer.append(':');
    buffer.append(name);
    String tagName = buffer.toString();
    // check if valid (defined) SSI tag or not
    if (map.getNamedItem(tagName) == null) {
      return null;
    }

    CommentElementFactory factory = new CommentElementFactory(document, isJSPTag, this);
    Element element = factory.create(tagName, CommentElementFactory.IS_START);
View Full Code Here

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

    }
    CMDocument cm = modelQuery.getCorrespondingCMDocument(document);
    if (cm == null) {
      return false;
    }
    CMNamedNodeMap map = cm.getElements();
    if (map == null) {
      return false;
    }
    String prefix = element.getPrefix();
    if (prefix == null || !prefix.equals(SSI_PREFIX)) {
      return false;
    }
    String tagName = element.getTagName();
    if (tagName.length() <= 4) {
      return false;
    }
    if (map.getNamedItem(tagName) == null) {
      return false;
    }
    else {
      return true;
    }
View Full Code Here

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

      return; // cannot validate.
    if (!CMUtil.isHTML(dec))
      return; // no need to validate
    if (!dec.supports(HTMLCMProperties.PROHIBITED_ANCESTORS))
      return; // cannot validate.
    CMNamedNodeMap prohibited = (CMNamedNodeMap) dec.getProperty(HTMLCMProperties.PROHIBITED_ANCESTORS);
    if (prohibited.getLength() <= 0)
      return; // no prohibited ancestors.

    Element parent = SMUtil.getParentElement(target);
    while (parent != null) {
      CMNode pdec = prohibited.getNamedItem(parent.getNodeName());
      if (pdec != null) { // prohibited element is found in ancestors.
        Segment errorSeg = FMUtil.getSegment((IDOMNode) node, FMUtil.SEG_START_TAG);
        if (errorSeg != null)
          reporter.report(new ErrorInfoImpl(ErrorState.INVALID_CONTENT_ERROR, errorSeg, target));
        break; // If one prohibited ancestor is found, it's enough.
View Full Code Here

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

    buffer.append("\n\t tag class:" + StringUtils.escape(getTagclass())); //$NON-NLS-1$
    buffer.append("\n\t tei class:" + StringUtils.escape(getTeiclass())); //$NON-NLS-1$
    buffer.append("\n\t body content:" + StringUtils.escape(getBodycontent())); //$NON-NLS-1$
    buffer.append("\n\t description (info):" + StringUtils.escape(getDescription())); //$NON-NLS-1$
    buffer.append("\n\t attributes:"); //$NON-NLS-1$
    CMNamedNodeMap attributes = getAttributes();
    for (int i = 0; i < attributes.getLength(); i++) {
      buffer.append("\n\t\t" + StringUtils.replace(attributes.item(i).toString(), "\n", "\n\t\t")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    }
    buffer.append("\n\t variables:"); //$NON-NLS-1$
    for (int i = 0; i < getVariables().size(); i++) {
      buffer.append("\n\t\t" + StringUtils.replace(getVariables().get(i).toString(), "\n", "\n\t\t")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    }
View Full Code Here

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

      if (mqAdapter != null) {
        CMDocument doc = mqAdapter.getModelQuery().getCorrespondingCMDocument(node);
        if (doc != null) {
          CMDocument jcmdoc = getDefaultJSPCMDocument(node);
          CMNamedNodeMap jspelements = jcmdoc.getElements();

          /* For a built-in JSP action the content model is properly
           * set up, so don't just blindly add the rest--unless this
           * will be a direct child of the document
           */
          if (jspelements != null && (!(doc instanceof JSPCMDocument) || node.getNodeType() == Node.DOCUMENT_NODE)) {
            List rejectElements = new ArrayList();

            // determine if the document is in XML form
            Document domDoc = null;
            if (node.getNodeType() == Node.DOCUMENT_NODE) {
              domDoc = (Document) node;
            } else {
              domDoc = node.getOwnerDocument();
            }

            // Show XML tag forms of JSP markers if jsp:root is
            // the document element OR it's HTML but
            // isn't really in the text.
            // If the document isn't strictly XML, pull out the
            // XML tag forms it is xml format
            rejectElements.add(JSP12Namespace.ElementName.SCRIPTLET);
            rejectElements.add(JSP12Namespace.ElementName.EXPRESSION);
            rejectElements.add(JSP12Namespace.ElementName.DECLARATION);
            rejectElements.add(JSP12Namespace.ElementName.DIRECTIVE_INCLUDE);
            rejectElements.add(JSP12Namespace.ElementName.DIRECTIVE_PAGE);
            rejectElements.add(JSP12Namespace.ElementName.TEXT);
            rejectElements.add(JSP12Namespace.ElementName.DIRECTIVE_TAGLIB);
            rejectElements.add(JSP20Namespace.ElementName.DIRECTIVE_TAG);
            rejectElements.add(JSP20Namespace.ElementName.DIRECTIVE_ATTRIBUTE);
            rejectElements.add(JSP20Namespace.ElementName.DIRECTIVE_VARIABLE);
            if (isXMLFormat(domDoc)) {
              // jsp actions
              rejectElements.add(JSP12Namespace.ElementName.FALLBACK);
              rejectElements.add(JSP12Namespace.ElementName.USEBEAN);
              rejectElements.add(JSP12Namespace.ElementName.GETPROPERTY);
              rejectElements.add(JSP12Namespace.ElementName.SETPROPERTY);
              rejectElements.add(JSP12Namespace.ElementName.INCLUDE);
              rejectElements.add(JSP12Namespace.ElementName.FORWARD);
              rejectElements.add(JSP12Namespace.ElementName.PLUGIN);
              rejectElements.add(JSP12Namespace.ElementName.FALLBACK);
              rejectElements.add(JSP12Namespace.ElementName.PARAM);
              rejectElements.add(JSP12Namespace.ElementName.PARAMS);
            }


            // don't show jsp:root if a document element already
            // exists
            Element docElement = domDoc.getDocumentElement();
            if (docElement != null &&((docElement.getNodeName().equals(TAG_JSP_ROOT)) ||
                ((((IDOMNode) docElement).getStartStructuredDocumentRegion() != null ||
                    ((IDOMNode) docElement).getEndStructuredDocumentRegion() != null)))) {
             
              rejectElements.add(JSP12Namespace.ElementName.ROOT);
            }
            //Add JSP elements into autocomplete menu
            for (int j = 0; j < jspelements.getLength(); j++) {
              CMElementDeclaration ed = (CMElementDeclaration) jspelements.item(j);
              if (!rejectElements.contains(ed.getNodeName())) {
                nodeList.add(ed);
              }
            }
           
           
            //Add Tapestry components into autocomplete menu
            ElemDecl temp = null;
            jcmdoc = getDefaultTapestryCMDocument();
            CMNamedNodeMap tapestryelements = jcmdoc.getElements();
            for (int j = 0; j < tapestryelements.getLength(); j++) {
              if(j == 0) temp =  (ElemDecl) tapestryelements.item(j);
              CMElementDeclaration ed = (CMElementDeclaration) tapestryelements.item(j);
              if (!rejectElements.contains(ed.getNodeName())) {
                nodeList.add(ed);
              }
            } 
           
            //load tapestry 5 custom components
            if(temp != null){
              collectCustomComponents();
              if(tapestryCustomComponents != null){
                for(int i=0; i<tapestryCustomComponents.size(); i++){
                  TapestryComponentModel tcm = tapestryCustomComponents.get(i);
                  ElemDecl cloneElement = (ElemDecl) temp.clone(tcm.nodeName, tcm.attributes);
                  nodeList.add(cloneElement);
                }
              }
            }
          }
        }
        // No cm document (such as for the Document (a non-Element) node itself)
        else {
          CMNamedNodeMap jspElements = getDefaultJSPCMDocument(node).getElements();
          int length = jspElements.getLength();
          for (int i = 0; i < length; i++) {
            nodeList.add(jspElements.item(i));
          }
        }
      }
     
      nodes = (CMNode[])nodeList.toArray(new CMNode[nodeList.size()]);
View Full Code Here

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

    modelQueryAssociationProvider = new HTMLModelQueryAssociationProvider(fCache, newIdResolver);
  }

  // utilities
  private static boolean isExcluded(CMElementDeclaration candidate, Element target) {
    CMNamedNodeMap prohibited = getProhibitedAncestors(candidate);
    if (prohibited == null)
      return false;
    Element parent = target;
    while (parent != null) {
      CMNode pdec = prohibited.getNamedItem(parent.getNodeName());
      if (pdec != null)
        return true;
      parent = getExplicitParentElement(parent);
    }
    return false;
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.