Examples of CMNodeList


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

    if ((parent != null) && (parent.getNodeType() == Node.ELEMENT_NODE)) {
      CMElementDeclaration decl = fModelUtil.getModelQuery().getCMElementDeclaration((Element) parent);
      CMContent content = decl.getContent();
      if (content instanceof CMGroup) {
        CMGroup cmGroup = (CMGroup) content;
        CMNodeList children = cmGroup.getChildNodes();
        CMNode cmNode = null;
        for (int i = 0; i < children.getLength(); i++) {
          cmNode = children.item(i);
          contextString = cmNode.getNodeName();
          if (contextString != null) {
            info.append("<" + cmNode.getNodeName() + ">"); //$NON-NLS-1$ //$NON-NLS-2$
            if (i < children.getLength() - 1) {
              info.append(" "); //$NON-NLS-1$
            }
          }
        }
      }
View Full Code Here

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

        if (isWholeTagOmissible((CMElementDeclaration) content))
          if (isChild(((CMElementDeclaration) content).getContent(), target))
            return true;
        return isSameDeclaration((CMElementDeclaration) content, target);
      case CMNode.GROUP :
        CMNodeList children = ((CMGroup) content).getChildNodes();
        for (int i = 0; i < children.getLength(); i++) {
          CMNode child = children.item(i);
          switch (child.getNodeType()) {
            case CMNode.ELEMENT_DECLARATION :
              if (isWholeTagOmissible((CMElementDeclaration) child))
                if (isChild(((CMElementDeclaration) child).getContent(), target))
                  return true;
View Full Code Here

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

   * Returns child CMNodeList, which includes ElementDefinition or CMElement.
   */
  public CMNodeList getChildNodes() {
    if (fChildNodes == null) {
      CMNodeListImpl childNodes = new CMNodeListImpl();
      CMNodeList children = fGroup.getChildNodes();
      for (int i = 0; i < children.getLength(); i++) {
        CMNode child = children.item(i);
        if (child instanceof CMGroup)
          childNodes.appendItem(new CMGroupWrapperImpl(fPrefix, (CMGroup) child));
        else if (child instanceof CMElementDeclaration)
          childNodes.appendItem(new CMElementDeclarationWrapperImpl(fPrefix, (CMElementDeclaration) child));
        else
View Full Code Here

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

    }
    return null;
  }

  private static void extractDeclarations(Hashtable availables, CMGroup group) {
    CMNodeList content = group.getChildNodes();
    for (int i = 0; i < content.getLength(); i++) {
      CMNode cmn = content.item(i);
      if (cmn == null || cmn.getNodeType() != CMNode.ELEMENT_DECLARATION)
        continue;
      addInclusion(availables, (CMElementDeclaration) cmn);
    }
  }
View Full Code Here

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

  private static boolean isChild(CMContent content, CMElementDeclaration target) {
    switch (content.getNodeType()) {
      case CMNode.ELEMENT_DECLARATION :
        return isSameDeclaration((CMElementDeclaration) content, target);
      case CMNode.GROUP :
        CMNodeList children = ((CMGroup) content).getChildNodes();
        for (int i = 0; i < children.getLength(); i++) {
          CMNode child = children.item(i);
          switch (child.getNodeType()) {
            case CMNode.ELEMENT_DECLARATION :
              if (isSameDeclaration((CMElementDeclaration) child, target))
                return true;
              continue; // Go next child.
View Full Code Here

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

        result = name.equalsIgnoreCase(element.getElementName());       

        // TODO... here's we consider substitution groups... revisit to see if this should be moved into validator code
        if (!result)
        {
          CMNodeList cmNodeList = (CMNodeList)element.getProperty("SubstitutionGroup");   //$NON-NLS-1$
          if (cmNodeList != null)
          {
            int cmNodeListLength = cmNodeList.getLength();
            if (cmNodeListLength > 1)
            {                       
              for (int i = 0; i < cmNodeListLength; i++)
              {                                                              
                CMElementDeclaration alternativeCMElementDeclaration = (CMElementDeclaration)cmNodeList.item(i);
                String altName = alternativeCMElementDeclaration.getElementName();
                result = name.equalsIgnoreCase(altName);
                if (result)
                {
                  break;
View Full Code Here

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

    {
      CMGroup cmGroup = (CMGroup)cmNode;
      if (cmGroup.getOperator() == CMGroup.CHOICE && cmGroup.getMaxOccur() == -1)
      {                  
        result = true;
        CMNodeList list = cmGroup.getChildNodes();
        for (int i = list.getLength() - 1; i >= 0; i--)
        {
          if (list.item(i).getNodeType() != CMNode.ELEMENT_DECLARATION)
          {
            result = false;
            break;
          }
        }
View Full Code Here

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

        if (childEd != null)
        {        

          CMNode childOrigin= modelQuery.getOrigin(childElement);

          CMNodeList cmNodeList = childOrigin != null ?
                                    (CMNodeList)childOrigin.getProperty("SubstitutionGroup") : //$NON-NLS-1$
                                    (CMNodeList)childEd.getProperty("SubstitutionGroup"); //$NON-NLS-1$

          if (cmNodeList != null && cmNodeList.getLength() > 1)
          {                                                
            int replaceIndex = getIndex(parent, childElement);
            String childEdName = childEd.getNodeName();
            for (int i = 0; i < cmNodeList.getLength(); i++)
            {        
              CMNode substitution = cmNodeList.item(i);
              if (!substitution.getNodeName().equals(childEdName) && !Boolean.TRUE.equals(substitution.getProperty("Abstract"))) //$NON-NLS-1$
              {
                Action action = new Action(ModelQueryAction.REPLACE, parent, cmNodeList.item(i), replaceIndex, replaceIndex);
                actionList.add(action);
              }
            }
          }
        }
View Full Code Here

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

  private void validatAllGroupContent(List elementContent, ElementContentComparator comparator, CMGroup allGroup, Result result)
  {
    boolean isValid = true;
    boolean isPartiallyValid = true;
    HashMap map = new HashMap();
    CMNodeList list = allGroup.getChildNodes();
    for (int j = list.getLength() - 1; j >= 0; j--)
    {
      CMNode node = list.item(j);     
      if (map.get(node) == null)
      { 
        map.put(node, new ItemCount());
     
    }   
    int validitionCount = 0;
    for (Iterator i = elementContent.iterator(); i.hasNext(); validitionCount++)
    {
      Object o = i.next();       
      if (comparator.isElement(o))
      {             
        // test to see if the element is listed in the all group
        //
        CMNode matchingCMNode = null;
        for (int j = list.getLength() - 1; j >= 0; j--)
        {
          CMNode node = list.item(j);
          if (comparator.matches(o, node))
          {
            matchingCMNode = node;
            break;
          }            
        }                             
        if (matchingCMNode == null)
        {    
          isPartiallyValid = false;
          isValid = false;
          break;
        }
        else
       
          // test to see that the element occurs only once
          //
          ItemCount itemCount = (ItemCount)map.get(matchingCMNode);
          if (itemCount != null)
          { 
            if (itemCount.count > 0)
            {
              // we don't want to allow too many elements!
              // we consider 'not enough' to be partially valid... but not 'too many'
              isPartiallyValid = false;
              break;
           
            else
            {
              itemCount.count++;
           
          }
        } 
      } 
    }
    if (isValid)
    { 
      for (int j = list.getLength() - 1; j >= 0; j--)
      {
        CMNode node = list.item(j);     
        if (node.getNodeType() == CMNode.ELEMENT_DECLARATION)
        { 
          CMContent content = (CMContent)node;
          ItemCount itemCount = (ItemCount)map.get(node);
//          System.out.print("content " + content.getNodeName() + " " + content.getMinOccur());
View Full Code Here

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

        if (!Boolean.TRUE.equals(ed.getProperty("Abstract"))) //$NON-NLS-1$
        {
          addToTable(childNodeTable,ed);
        }

        CMNodeList substitutionGroup = (CMNodeList)ed.getProperty("SubstitutionGroup"); //$NON-NLS-1$
        if (substitutionGroup != null)
        {
          handleSubstitutionGroup(substitutionGroup);
        }
      }
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.