use of org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap in project webtools.sourceediting by eclipse.
the class TestTaglibCMTests method testDynamicAttributes.
public void testDynamicAttributes() throws Exception {
final String testName = "testDynamicAttributes";
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(testName);
if (!project.exists()) {
project = BundleResourceUtil.createSimpleProject(testName, null, null);
BundleResourceUtil.copyBundleEntriesIntoWorkspace(TESTFILES_PATHSTRING + "testDynamicAttributes", "/testDynamicAttributes");
}
project.refreshLocal(IResource.DEPTH_INFINITE, null);
CMDocumentFactoryTLD factory = new CMDocumentFactoryTLD();
ITaglibRecord[] records = TaglibIndex.getAvailableTaglibRecords(new Path("/" + testName + "/"));
assertEquals("There should only be one taglib record", 1, records.length);
CMDocument document = factory.createCMDocument(records[0]);
CMNamedNodeMap elements = document.getElements();
assertNotNull("No elements for the CM Document", elements);
CMNode node = elements.getNamedItem("bar");
assertTrue("Node must be a CMElementDeclarationImpl", node instanceof CMElementDeclarationImpl);
assertEquals("Dynamic attributes must be set to 'true'", "true", ((CMElementDeclarationImpl) node).getDynamicAttributes());
}
use of org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap in project webtools.sourceediting by eclipse.
the class TestTaglibCMTests method testTagRuntimeExpressionValues.
public void testTagRuntimeExpressionValues() throws Exception {
final String testName = "testLoadTagFiles";
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(testName);
if (!project.exists()) {
project = BundleResourceUtil.createSimpleProject(testName, null, null);
BundleResourceUtil.copyBundleEntriesIntoWorkspace(TESTFILES_PATHSTRING + testName, "/" + testName);
}
project.refreshLocal(IResource.DEPTH_INFINITE, null);
CMDocumentFactoryTLD factory = new CMDocumentFactoryTLD();
ITaglibRecord[] records = TaglibIndex.getAvailableTaglibRecords(new Path("/" + testName + "/"));
assertEquals("There should only be one taglib record", 1, records.length);
CMDocument document = factory.createCMDocument(records[0]);
CMNamedNodeMap elements = document.getElements();
assertNotNull("No elements for the CM Document", elements);
CMNode node = elements.getNamedItem("test");
assertTrue("Node must be a CMElementDeclarationImpl", node instanceof CMElementDeclarationImpl);
CMNamedNodeMap attributes = ((CMElementDeclaration) node).getAttributes();
assertNotNull("No attributes", attributes);
node = attributes.getNamedItem("myAttr");
assertTrue("Node must be a CMAttributeDeclarationImpl", node instanceof CMAttributeDeclarationImpl);
assertEquals("Default rtexprvalue for tags should be true", JSP11Namespace.ATTR_VALUE_TRUE, ((CMAttributeDeclarationImpl) node).getRtexprvalue());
node = attributes.getNamedItem("noRuntimeAttr");
assertTrue("Node must be a CMAttributeDeclarationImpl", node instanceof CMAttributeDeclarationImpl);
assertEquals("rtexprvalue for should be false since explicitly set", JSP11Namespace.ATTR_VALUE_FALSE, ((CMAttributeDeclarationImpl) node).getRtexprvalue());
}
use of org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap in project webtools.sourceediting by eclipse.
the class ElementNodeCleanupHandler method getRequiredAttrs.
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) {
result.add(attr);
}
}
}
}
return result;
}
use of org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap in project webtools.sourceediting by eclipse.
the class CommentElementHandlerForSSI method isCommentElement.
public boolean isCommentElement(IDOMElement element) {
if (element == null) {
return false;
}
Document document = element.getOwnerDocument();
ModelQuery modelQuery = ModelQueryUtil.getModelQuery(document);
if (modelQuery == null) {
return false;
}
CMDocument cm = modelQuery.getCorrespondingCMDocument(document);
if (cm == null) {
return false;
}
CMNamedNodeMap map = cm.getElements();
if (map == null) {
return false;
}
String prefix = element.getPrefix();
if (prefix == null || !prefix.equals(SSI_PREFIX)) {
return false;
}
String tagName = element.getTagName();
if (tagName.length() <= 4) {
return false;
}
if (map.getNamedItem(tagName) == null) {
return false;
} else {
return true;
}
}
use of org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap in project webtools.sourceediting by eclipse.
the class TestFixedCMDocuments method verifyElementDeclarationHasName.
private void verifyElementDeclarationHasName(CMNode item) {
assertTrue(item.getNodeType() == CMNode.ELEMENT_DECLARATION);
assertNotNull("no name on an element declaration", item.getNodeName());
CMNamedNodeMap attrs = ((CMElementDeclaration) item).getAttributes();
for (int i = 0; i < attrs.getLength(); i++) {
CMNode attr = attrs.item(i);
verifyAttributeDeclaration(((CMElementDeclaration) item), attr);
}
}
Aggregations