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);
}
}
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);
}
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));
}
}
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;
}
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);
}
Aggregations