Package org.eclipse.wst.xml.core.internal.contentmodel

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


      // We do not check for a conflict between a DTD's 'fixed' value
      // and the attribute value found in the instance document, we
      // leave that to the validator.
      if (!sawXmlSpace) {
        ModelQueryAdapter adapter = (ModelQueryAdapter) ((IDOMDocument) node.getOwnerDocument()).getAdapterFor(ModelQueryAdapter.class);
        CMElementDeclaration elementDeclaration = (CMElementDeclaration) adapter.getModelQuery().getCMNode(node);
        if (elementDeclaration != null) {
          int contentType = elementDeclaration.getContentType();
          if (preferences.isPreservePCDATAContent() && contentType == CMElementDeclaration.PCDATA) {
            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();
View Full Code Here


            }

            // try referring to content model for information on
            // whitespace & indent strategy
            ModelQueryAdapter adapter = (ModelQueryAdapter) ((IDOMDocument) currentNode.getOwnerDocument()).getAdapterFor(ModelQueryAdapter.class);
            CMElementDeclaration elementDeclaration = (CMElementDeclaration) adapter.getModelQuery().getCMNode(currentNode);
            if (elementDeclaration != null) {
              // follow whitespace strategy preference for
              // pcdata content
              int contentType = elementDeclaration.getContentType();
             
              String facetValue = null;
              if(elementDeclaration.getDataType() != null)
                facetValue = (String) elementDeclaration.getDataType().getProperty(PROPERTY_WHITESPACE_FACET);
              if(facetValue != null) {
                if(PRESERVE.equals(facetValue))
                  childConstraints.setWhitespaceStrategy(XMLFormattingConstraints.PRESERVE);
                // For XSD types, "collapse" corresponds to the IGNOREANDTRIM strategy
                else if(COLLAPSE.equals(facetValue))
                  childConstraints.setWhitespaceStrategy(XMLFormattingConstraints.IGNOREANDTRIM);
                else if(REPLACE.equals(facetValue))
                  childConstraints.setWhitespaceStrategy(XMLFormattingConstraints.REPLACE);
              }
              else if (contentType == CMElementDeclaration.PCDATA && parentConstraints != null && !XMLFormattingConstraints.PRESERVE.equals(parentConstraints.getWhitespaceStrategy())) {
                childConstraints.setWhitespaceStrategy(preferences.getPCDataWhitespaceStrategy());
              }
              else if (contentType == CMElementDeclaration.ELEMENT && parentConstraints != null && !XMLFormattingConstraints.PRESERVE.equals(parentConstraints.getWhitespaceStrategy())) {
                childConstraints.setWhitespaceStrategy(XMLFormattingConstraints.IGNORE);
                childConstraints.setIndentStrategy(XMLFormattingConstraints.INDENT);
                childConstraints.setIsWhitespaceStrategyAHint(true);
                childConstraints.setIsIndentStrategyAHint(true);
              }
              else {
                // look for xml:space in content model
                CMNamedNodeMap cmAttributes = elementDeclaration.getAttributes();

                // Not needed - we're looking for xml:space
                //CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(cmAttributes);
                //List nodes = ModelQueryUtil.getModelQuery(currentNode.getOwnerDocument()).getAvailableContent((Element) currentNode, elementDeclaration, ModelQuery.INCLUDE_ATTRIBUTES);
                //for (int k = 0; k < nodes.size(); k++) {
View Full Code Here

    ModelQuery modelQuery = ModelQueryUtil.getModelQuery(document);
    if (modelQuery == null)
      // undefined tag, return default
      return false;

    CMElementDeclaration decl = modelQuery.getCMElementDeclaration(element);
    if (decl == null)
      // undefined tag, return default
      return false;

    return (decl.getContentType() == CMElementDeclaration.EMPTY);
  }
View Full Code Here

  protected List getRequiredAttrs(Node node) {
    List result = new ArrayList();

    ModelQuery modelQuery = getModelQuery(node);
    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) {
View Full Code Here

    if (isJSPTag()) {
      // exclude JSP directive
      return (matchTagName(JSPTag.JSP_SCRIPTLET) || matchTagName(JSPTag.JSP_DECLARATION) || matchTagName(JSPTag.JSP_EXPRESSION));
    }
    if (!isXMLTag()) { // non-XML tag
      CMElementDeclaration decl = getDeclaration();
      if (decl == null)
        return true; // undefined tag
      return (decl.getContentType() != CMElementDeclaration.EMPTY);
    }
    return true;
  }
View Full Code Here

      return false;
    if (isCommentTag())
      return false;
    if (!isXMLTag())
      return false;
    CMElementDeclaration decl = getDeclaration();
    if (decl == null)
      return false;
    return (decl.getContentType() == CMElementDeclaration.EMPTY);
  }
View Full Code Here

  /**
   * @param ele
   * @return true if supports the style attribute
   */
  public static boolean supportStyleAttribute(IDOMElement ele) {
    CMElementDeclaration decl = CMUtil.getElementDeclaration(ele);
    if (decl != null && decl.getAttributes().getNamedItem(STYLE_ATTR) != null) {
      return true;
    }
        return false;
  }
View Full Code Here

          break;
        }
      }
     
      // on an empty value, add all the JSP and taglib tags
      CMElementDeclaration elementDecl =
        AbstractXMLModelQueryCompletionProposalComputer.getCMElementDeclaration(node);
      if (nameRegion != null && elementDecl != null) {
        String attributeName = open.getText(nameRegion);
        if (attributeName != null) {
          Node parent = contentAssistRequest.getParent();
         
          //ignore start quote in match string
          String matchString = contentAssistRequest.getMatchString().trim();
          if(matchString.startsWith("'") || matchString.startsWith("\"")) { //$NON-NLS-1$ //$NON-NLS-2$
            matchString = matchString.substring(1);
          }
         
          //get all the proposals
          List additionalElements = ModelQueryUtil.getModelQuery(node.getOwnerDocument()).getAvailableContent(
              (Element) node, elementDecl, ModelQuery.INCLUDE_ALL);
          Iterator nodeIterator = additionalElements.iterator();
         
          //check each suggestion
          while (nodeIterator.hasNext()) {
            CMNode additionalElementDecl = (CMNode) nodeIterator.next();
            if (additionalElementDecl != null && additionalElementDecl instanceof CMElementDeclaration &&
                validModelQueryNode(additionalElementDecl)) {
              CMElementDeclaration ed = (CMElementDeclaration) additionalElementDecl;
              // https://bugs.eclipse.org/bugs/show_bug.cgi?id=89811
              StringBuffer sb = new StringBuffer();
              getContentGenerator().generateTag(parent, ed, sb);
 
              String proposedText = sb.toString();
View Full Code Here

    if (!isXMLFormat(document)) {
      List additionalElements = forciblyGetTagLibAndJSPElements(new ArrayList(), document, childPosition);
     
      //convert CMElementDeclartions to proposals
      for (int i = 0; i < additionalElements.size(); i++) {
        CMElementDeclaration ed = (CMElementDeclaration) additionalElements.get(i);
        if (ed != null) {
          Image image = CMImageUtil.getImage(ed);
          if (image == null) {
            image = this.getGenericTagImage();
          }
View Full Code Here

          for (int i = 0; i < moreCMDocuments.size(); i++) {
            CMDocument doc = (CMDocument) moreCMDocuments.get(i);
            CMNamedNodeMap elements = doc.getElements();
            if (elements != null) {
              for (int j = 0; j < elements.getLength(); j++) {
                CMElementDeclaration ed = (CMElementDeclaration) elements.item(j);
                elementDecls.add(ed);
              }
            }
          }
        }
      }

      // get position dependent CMDocuments and insert their tags as
      // proposals

      ModelQueryAdapter mqAdapter = null;
      if (node.getNodeType() == Node.DOCUMENT_NODE)
        mqAdapter = (ModelQueryAdapter) ((IDOMNode) node).getAdapterFor(ModelQueryAdapter.class);
      else
        mqAdapter = (ModelQueryAdapter) ((IDOMNode) node.getOwnerDocument()).getAdapterFor(ModelQueryAdapter.class);

      if (mqAdapter != null) {
        CMDocument doc = mqAdapter.getModelQuery().getCorrespondingCMDocument(node);
        if (doc != null) {
          CMDocument jcmdoc = getDefaultJSPCMDocument((IDOMNode) 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("jsp:root")) || ((((IDOMNode) docElement).getStartStructuredDocumentRegion() != null || ((IDOMNode) docElement).getEndStructuredDocumentRegion() != null)))) //$NON-NLS-1$
              rejectElements.add(JSP12Namespace.ElementName.ROOT);

            for (int j = 0; j < jspelements.getLength(); j++) {
              CMElementDeclaration ed = (CMElementDeclaration) jspelements.item(j);
              if (rejectElements.contains(ed.getNodeName()))
                continue;
              elementDecls.add(ed);
            }

          }
View Full Code Here

TOP

Related Classes of org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration

Copyright © 2018 www.massapicom. 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.