Search in sources :

Example 1 with CMNodeList

use of org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList in project webtools.sourceediting by eclipse.

the class HMQUtil method extractDeclarations.

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);
    }
}
Also used : CMNode(org.eclipse.wst.xml.core.internal.contentmodel.CMNode) CMNodeList(org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList)

Example 2 with CMNodeList

use of org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList in project webtools.sourceediting by eclipse.

the class DOMValidator method canInsert.

/**
 */
public boolean canInsert(CMElementDeclaration ed, List contentSpecificationList, int insertIndex, List cmNodeList) {
    List clonedList = clone(contentSpecificationList);
    insert(clonedList, insertIndex, cmNodeList);
    return isValid(ed, clonedList);
}
Also used : List(java.util.List) CMNodeList(org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList)

Example 3 with CMNodeList

use of org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList in project webtools.sourceediting by eclipse.

the class CMVisitor method visitCMGroup.

public void visitCMGroup(CMGroup group) {
    CMNodeList nodeList = group.getChildNodes();
    int size = nodeList.getLength();
    for (int i = 0; i < size; i++) {
        visitCMNode(nodeList.item(i));
    }
}
Also used : CMNodeList(org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList)

Example 4 with CMNodeList

use of org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList in project webtools.sourceediting by eclipse.

the class CMGroupWrapperImpl method getChildNodes.

/**
 * getChildNodes method
 * @return 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
                // error?
                childNodes.appendItem(new CMNodeWrapperImpl(fPrefix, child));
        }
        fChildNodes = childNodes;
    }
    return fChildNodes;
}
Also used : CMGroup(org.eclipse.wst.xml.core.internal.contentmodel.CMGroup) CMElementDeclaration(org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration) CMNode(org.eclipse.wst.xml.core.internal.contentmodel.CMNode) CMNodeList(org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList)

Example 5 with CMNodeList

use of org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList in project webtools.sourceediting by eclipse.

the class ModelQueryTester method testHtmlChildren.

/**
 * Test the HTML HTML Element for its declared children
 */
public void testHtmlChildren() {
    setUpHTML();
    // set text
    fModel.getStructuredDocument().set("<html></html>");
    Element htmlElement = fModel.getDocument().getDocumentElement();
    CMElementDeclaration htmlDecl = fModelQuery.getCMElementDeclaration(htmlElement);
    // HTML's children are within a group
    CMContent contents = htmlDecl.getContent();
    assertTrue("content type is not a group", contents.getNodeType() == CMNode.GROUP);
    CMGroup group = (CMGroup) contents;
    int operator = group.getOperator();
    CMNodeList childList = group.getChildNodes();
    int max = contents.getMaxOccur();
    int min = contents.getMinOccur();
    // the group should be allowed once, with a sequence whose first entry
    // is the declaration for HEAD
    assertTrue("occurrance of group", min == 1 && max == 1);
    assertTrue("relationship in group", operator == CMGroup.SEQUENCE);
    assertTrue("content descriptor type, position 0", contents.getNodeType() == CMNode.GROUP);
    assertTrue("child order (HEAD first)", childList.item(0).getNodeName().equalsIgnoreCase(HTML40Namespace.ElementName.HEAD));
    assertTrue("content descriptor type, position 1", childList.item(1).getNodeType() == CMNode.GROUP);
    // The second child should be a group as well, containing BODY and
    // FRAMESET with an
    // operator of CMGroup.CHOICE
    assertTrue("content descriptor type, position 1 - relationship of group", ((CMGroup) childList.item(1)).getOperator() == CMGroup.CHOICE);
}
Also used : CMGroup(org.eclipse.wst.xml.core.internal.contentmodel.CMGroup) CMElementDeclaration(org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration) Element(org.w3c.dom.Element) CMContent(org.eclipse.wst.xml.core.internal.contentmodel.CMContent) CMNodeList(org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList)

Aggregations

CMNodeList (org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList)23 CMNode (org.eclipse.wst.xml.core.internal.contentmodel.CMNode)9 CMElementDeclaration (org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration)8 CMAttributeDeclaration (org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration)5 CMGroup (org.eclipse.wst.xml.core.internal.contentmodel.CMGroup)5 DocumentationImpl (org.eclipse.wst.xsd.contentmodel.internal.XSDImpl.DocumentationImpl)5 CMContent (org.eclipse.wst.xml.core.internal.contentmodel.CMContent)4 Node (org.w3c.dom.Node)3 URL (java.net.URL)2 List (java.util.List)2 CMDocument (org.eclipse.wst.xml.core.internal.contentmodel.CMDocument)2 Element (org.w3c.dom.Element)2 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 Vector (java.util.Vector)1 ContextInformation (org.eclipse.jface.text.contentassist.ContextInformation)1 IContextInformation (org.eclipse.jface.text.contentassist.IContextInformation)1 CMDataType (org.eclipse.wst.xml.core.internal.contentmodel.CMDataType)1 CMDocumentation (org.eclipse.wst.xml.core.internal.contentmodel.CMDocumentation)1 CMNamedNodeMap (org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap)1