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

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


    IndexedRegion ir = model.getIndexedRegion(documentRegion.getStartOffset());
    if (ir instanceof IDOMElement) {
      IDOMElement element = (IDOMElement) ir;
      ModelQuery query = ModelQueryUtil.getModelQuery(model);
      if (query != null) {
        CMElementDeclaration cmElement = query.getCMElementDeclaration(element);
        if (cmElement != null) {
          CMNamedNodeMap cmAttributes = null;

          CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl();
          List nodes = query.getAvailableContent(element, cmElement, ModelQuery.INCLUDE_ATTRIBUTES);
View Full Code Here


      return false;
    Node parent = node.getParentNode();
    if (parent == null || parent.getNodeType() != Node.ELEMENT_NODE)
      return false;

    CMElementDeclaration decl = getElementDeclaration((Element) parent);
    if (decl == null || (!decl.supports(HTMLCMProperties.LINE_BREAK_HINT)))
      return false;
    String hint = (String) decl.getProperty(HTMLCMProperties.LINE_BREAK_HINT);
    return hint.equals(HTMLCMProperties.Values.BREAK_BEFORE_START_AND_AFTER_END);
  }
View Full Code Here

      return false;
    Node parent = node.getParentNode();
    if (parent == null || parent.getNodeType() != Node.ELEMENT_NODE)
      return false;

    CMElementDeclaration decl = getElementDeclaration((Element) parent);
    if (decl == null || (!decl.supports(HTMLCMProperties.LINE_BREAK_HINT)))
      return false;
    String hint = (String) decl.getProperty(HTMLCMProperties.LINE_BREAK_HINT);
    return hint.equals(HTMLCMProperties.Values.BREAK_BEFORE_START_AND_AFTER_END);
  }
View Full Code Here

      if (nameRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME)
        break;
    }
   
    // on an empty value, add all the JSP and taglib tags
    CMElementDeclaration elementDecl = getCMElementDeclaration(node);
    if (nameRegion != null && elementDecl != null) {
      String attributeName = open.getText(nameRegion);
      if (attributeName != null) {
        String currentValue = node.getAttributes().getNamedItem(attributeName).getNodeValue();
       
        if(currentValue == null || currentValue.length() == 0) { //$NON-NLS-1$
          List additionalElements = ModelQueryUtil.getModelQuery(node.getOwnerDocument()).getAvailableContent((Element) node, elementDecl, ModelQuery.INCLUDE_ATTRIBUTES);
          for (i = 0; i < additionalElements.size(); i++) {
            Object additionalElement = additionalElements.get(i);
            if(additionalElement instanceof CMElementDeclaration) {
              CMElementDeclaration ed = (CMElementDeclaration) additionalElement;
 
              String tagname = getContentGenerator().getRequiredName(node, ed);
              StringBuffer contents = new StringBuffer("\""); //$NON-NLS-1$
              getContentGenerator().generateTag(node, ed, contents);
              contents.append('"'); //$NON-NLS-1$
View Full Code Here

   * @return the namespace URI
   */
  public static String getElementNamespaceURI(Element element) {
      //System.out.printf("uri for %s is %s\n", element.toString(), element.getNamespaceURI());

      CMElementDeclaration decl = getElementDeclaration(element);
    if (decl == null) {
       
        // if the content model has nothing, see if the element
        // itself has an xml namespace
        // TODO: should only apply this if the source document
View Full Code Here

  /**
   * @param element
   * @return true if the element can have children
   */
  public static boolean canHaveDirectTextChild(Element element) {
    CMElementDeclaration decl = getElementDeclaration(element);
    if (decl == null) {
      return true;
    }
    int contentType = decl.getContentType();
    return contentType != CMElementDeclaration.ELEMENT
        && contentType != CMElementDeclaration.EMPTY;

  }
View Full Code Here

       
        return uri;
    }

    public boolean isJSPTag() {
        CMElementDeclaration elemDecl = getElementDeclaration();
       
        if (elemDecl != null)
        {
            return CMUtil.isJSP(elemDecl);
        }
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

    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

      }
      else if (lastChild == null && firstStructuredDocumentRegionContainsLineDelimiters(node)) {
        // BUG174243 do not indent end tag if node has empty content
        // (otherwise new text node would be introduced)
        ModelQueryAdapter adapter = (ModelQueryAdapter) ((IDOMDocument) node.getOwnerDocument()).getAdapterFor(ModelQueryAdapter.class);
        CMElementDeclaration elementDeclaration = (CMElementDeclaration) adapter.getModelQuery().getCMNode(node);
        if ((elementDeclaration == null) || (elementDeclaration.getContentType() != CMElementDeclaration.EMPTY)) {
          // indent end tag
          replace(structuredDocument, node.getFirstStructuredDocumentRegion().getEndOffset(), 0, lineDelimiter + nodeIndentation);
        }
      }
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.