Examples of CMElementDeclaration


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

 
  private void validateContent(Element parent, Node child) {
    if (child == null)
      return;

    CMElementDeclaration ed = CMUtil.getDeclaration(parent);
    if(ed == null || ed.getContentType() == CMElementDeclaration.ANY)
      return;
   
    List[] extendedContent = new List[1];
    while (child != null) {
      // perform actual validation
View Full Code Here

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

        // is
        // an element of foreign markup languages, just ignore it.
        if (CMUtil.isForeign(childElem))
          return;

        CMElementDeclaration ced = CMUtil.getDeclaration((Element) child);
        // Defect 186774: If a child is not one of HTML elements,
        // it should be regarded as a valid child regardless the
        // type of the parent content model. -- 10/12/2001
        if (ced == null || CMUtil.isSSI(ced) || (!CMUtil.isHTML(ced)))
          return;
        if (CMUtil.isObsolete(ced)){
          error = ErrorState.OBSOLETE_TAG_NAME_ERROR;
          break;
        }
       
        switch (contentType) {
          case CMElementDeclaration.ANY :
            // Keep going.
            return;
          case CMElementDeclaration.ELEMENT :
          case CMElementDeclaration.MIXED :
            if (ced == null)
              return;
            if (CMUtil.isValidChild(edec, ced))
              return;
            // Now, it is the time to check inclusion, unless the
            // target
            // document is not a XHTML.
            if (!CMUtil.isXHTML(edec)) {
              // pure HTML
              if (CMUtil.isValidInclusion(ced, target))
                return;
            }
           
            /*
             * https://bugs.eclipse.org/bugs/show_bug.cgi?id=218143 -
             * ModelQuery use not pervasive enough
             */
            if (extendedContent[0] == null) {
              extendedContent[0] = ModelQueryUtil.getModelQuery(target.getOwnerDocument()).getAvailableContent(target, edec, ModelQuery.INCLUDE_CHILD_NODES);
            }

            List availableChildElementDeclarations = extendedContent[0];
            /*
             * Retrieve and set aside just the element names for faster checking
             * later.
             */
            int availableChildCount = availableChildElementDeclarations.size();
            String elementName = ced.getElementName().toLowerCase(Locale.US);
            for (int i = 0; i < availableChildCount; i++) {
              CMNode cmnode = (CMNode) availableChildElementDeclarations.get(i);
              if (cmnode.getNodeType() == CMNode.ELEMENT_DECLARATION && cmnode.getNodeName().toLowerCase(Locale.US).equals(elementName)) {
                return;
              }
View Full Code Here

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

   */
  public void validate(IndexedRegion node) {
    Element target = (Element) node;
    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;
View Full Code Here

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

   *
   * @see org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.
   * ModelQueryImpl#getCMElementDeclaration(org.w3c.dom.Element)
   */
  public CMElementDeclaration getCMElementDeclaration(Element element) {
    CMElementDeclaration cmElementDeclaration = super.getCMElementDeclaration(element);
    if (cmElementDeclaration == null) {
      ModelQuery embeddedModelQuery = getEmbeddedModelQuery(element);
      if (embeddedModelQuery != null) {
        return embeddedModelQuery.getCMElementDeclaration(element);
      }
View Full Code Here

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

      if (node.getNodeType() == Node.ELEMENT_NODE) {
        String elementName = node.getNodeName();

        // test to see if this node belongs to JSP's CMDocument (case
        // sensitive)
        CMElementDeclaration dec = (CMElementDeclaration) jcmdoc.getElements().getNamedItem(elementName);
        if (dec != null) {
          result = jcmdoc;
        }
      }
View Full Code Here

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

   */
  protected boolean canFormatChild(Node node) {
    while (node != null) {
      if (node.getNodeType() != Node.ELEMENT_NODE)
        return true;
      CMElementDeclaration decl = getElementDeclaration((Element) node);
      if (decl != null) {
        if (decl.getContentType() == CMElementDeclaration.CDATA)
          return false;
        if (decl.supports(HTMLCMProperties.SHOULD_KEEP_SPACE)) {
          boolean shouldKeepSpace = ((Boolean) decl.getProperty(HTMLCMProperties.SHOULD_KEEP_SPACE)).booleanValue();
          if (shouldKeepSpace)
            return false;
        }
      }
      node = node.getParentNode();
View Full Code Here

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

      // insert line break under non-HTML elements including JSP
      // elements
      if (element.getPrefix() != null)
        return true;

      CMElementDeclaration decl = getElementDeclaration(element);
      if (decl != null) {
        if (decl.getContentType() == CMElementDeclaration.ELEMENT)
          return true;
                // causes all closing tags to wrap to a new line
                boolean allowsText = decl.getContentType() == CMElementDeclaration.MIXED
                        || decl.getContentType() == CMElementDeclaration.PCDATA;
                if (allowsNewlineAfter(allowsText, node, element))
                    return true;
        String tagName = element.getTagName();
        // special for direct children under BODY
        if (tagName != null && tagName.equalsIgnoreCase(BODY_NAME))
          return true;
      }
    }

    if (node.getNodeType() == Node.ELEMENT_NODE) {
      IDOMElement element = (IDOMElement) node;
      CMElementDeclaration decl = getElementDeclaration(element);
      if (canInsertBreakAfter(decl)) {
        // spcial for BR
        return canFormatChild(parent);
      }
    }
    if (next != null && next.getNodeType() == Node.ELEMENT_NODE) {
      CMElementDeclaration decl = getElementDeclaration((Element) next);
      if (canInsertBreakBefore(decl))
        return true;
    }
    return false;
  }
View Full Code Here

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

      // insert line break under non-HTML elements including JSP
      // elements
      if (element.getPrefix() != null)
        return true;

      CMElementDeclaration decl = getElementDeclaration(element);
      if (decl != null) {
          return allowNewlineBefore(node, element);
      }
    }

    if (node.getNodeType() == Node.ELEMENT_NODE) {
      return true;
    }
    if (prev != null && prev.getNodeType() == Node.ELEMENT_NODE) {
      CMElementDeclaration decl = getElementDeclaration((Element) prev);
      if (canInsertBreakAfter(decl)) {
        // spcial for BR
        return canFormatChild(parent);
      }
    }
View Full Code Here

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

          String localName = element.getLocalName();
          if (HTML_NAME.equalsIgnoreCase(localName) || HEAD_NAME.equalsIgnoreCase(localName))
            break;
        }

        CMElementDeclaration decl = getElementDeclaration(element);
        if (decl != null && decl.supports(HTMLCMProperties.SHOULD_INDENT_CHILD_SOURCE)) {
          boolean shouldIndent = isIdentable(node, parent);
          if (shouldIndent)
            buffer.append(indent);
        }
View Full Code Here

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

  }

  public static boolean isValidInclusion(CMElementDeclaration decl, Element parent) {
    Iterator iter = HMQUtil.getInclusions(parent).iterator();
    while (iter.hasNext()) {
      CMElementDeclaration inclusion = (CMElementDeclaration) iter.next();
      if (isSameDeclaration(decl, inclusion))
        return true;
    }
    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.