use of org.eclipse.wst.xml.core.internal.contentmodel.CMNode 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.CMNode 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.CMNode in project webtools.sourceediting by eclipse.
the class CtdDl method createContent.
/**
* (DT | DD)+
*/
protected void createContent() {
if (content != null)
// already created.
return;
if (collection == null)
return;
// ( | )+
content = new CMGroupImpl(CMGroup.CHOICE, 1, CMContentImpl.UNBOUNDED);
// DT
CMNode dec = collection.getNamedItem(HTML40Namespace.ElementName.DT);
if (dec != null)
content.appendChild(dec);
// DD
dec = collection.getNamedItem(HTML40Namespace.ElementName.DD);
if (dec != null)
content.appendChild(dec);
}
use of org.eclipse.wst.xml.core.internal.contentmodel.CMNode in project webtools.sourceediting by eclipse.
the class CtdFieldset method createContent.
/**
* (#PCDATA, LEGEND, (%flow;)*)
*/
protected void createContent() {
if (content != null)
// already created.
return;
if (collection == null)
return;
// ( , , )
content = new CMGroupImpl(CMGroup.SEQUENCE, 1, 1);
// #PCDATA
// ...??
// LEGEND
CMNode dec = collection.getNamedItem(HTML40Namespace.ElementName.LEGEND);
if (dec != null)
content.appendChild(dec);
// (%flow;)*
CMGroupImpl flows = new CMGroupImpl(CMGroup.CHOICE, 0, CMContentImpl.UNBOUNDED);
if (flows == null)
return;
collection.getFlow(flows);
content.appendChild(flows);
}
use of org.eclipse.wst.xml.core.internal.contentmodel.CMNode in project webtools.sourceediting by eclipse.
the class CtdHead method createContent.
/**
* for HEAD.
* To avoid using inclusion, the content model comes from the XHTML 1.0.
*
* (%head.misc;, ((title, %head.misc;, (base, %head.misc;)?) | (base, %head.misc;, (title, %head.misc;))))
* And %head.misc; is:
* (script|style|meta|link|object|isindex)*
*
* 0: (%head.misc, A)
* A: (B | C)
* B: (title, %head.misc;, D)
* C: (base, %head.misc;, E)
* D: (base, %head.misc;)?
* E: (title, %head.misc;)
*/
protected void createContent() {
if (content != null)
// already created.
return;
if (collection == null)
return;
// At 1st, create %head.misc; content.
// %head.misc;
// ( | )*
CMGroupImpl misc = new CMGroupImpl(CMGroup.CHOICE, 0, CMContentImpl.UNBOUNDED);
if (misc == null)
return;
String[] names = { HTML40Namespace.ElementName.SCRIPT, HTML40Namespace.ElementName.STYLE, HTML40Namespace.ElementName.META, HTML40Namespace.ElementName.LINK, HTML40Namespace.ElementName.OBJECT, HTML40Namespace.ElementName.ISINDEX };
collection.getDeclarations(misc, Arrays.asList(names).iterator());
// 2nd, get a title
CMNode title = collection.getNamedItem(HTML40Namespace.ElementName.TITLE);
// 3rd, get a base
CMNode base = collection.getNamedItem(HTML40Namespace.ElementName.BASE);
if (title == null || base == null)
return;
// Top level content is a sequence of %head.misc; and A.
// 0: (%head.misc;, A)
// create a sequence
content = new CMGroupImpl(CMGroup.SEQUENCE, 1, 1);
if (content == null)
return;
// append %head.misc;
content.appendChild(misc);
// create A and append it to the top level.
{
// A is a choice of B and C.
// A: (B | C)
// create a choice
CMGroupImpl gA = new CMGroupImpl(CMGroup.CHOICE, 1, 1);
if (gA == null)
return;
// append A to the top level.
content.appendChild(gA);
// create B and append it to A
{
// B is a sequence of title, %head.misc;, and D.
// B: (title, %head.misc;, D)
// create a sequence
CMGroupImpl gB = new CMGroupImpl(CMGroup.SEQUENCE, 1, 1);
if (gB == null)
return;
// append B to A.
gA.appendChild(gB);
// append title to B
gB.appendChild(title);
// append %head.misc; to B
gB.appendChild(misc);
// create D and append it to B.
{
// D is a sequence of base, %head.misc;.
// D: (base, %head.misc;)?
// create a sequence
CMGroupImpl gD = new CMGroupImpl(CMGroup.SEQUENCE, 0, 1);
if (gD == null)
return;
// append D to B.
gB.appendChild(gD);
// append base to D
gD.appendChild(base);
// append %head.misc; to D.
gD.appendChild(misc);
}
}
// create C and append it to A
{
// C is a sequence of base, %head.misc;, and E
// C: (base, %head.misc;, E)
// create a sequence
CMGroupImpl gC = new CMGroupImpl(CMGroup.SEQUENCE, 1, 1);
if (gC == null)
return;
// append C to A.
gA.appendChild(gC);
// append base to C
gC.appendChild(base);
// append %head.misc; to C
gC.appendChild(misc);
// create E and append it to C.
{
// E is a sequence of title and %head.misc;.
// E: (title, %head.misc;)
// create a sequence
CMGroupImpl gE = new CMGroupImpl(CMGroup.SEQUENCE, 1, 1);
if (gE == null)
return;
// append E to C.
gC.appendChild(gE);
// append title to E
gE.appendChild(title);
// append %head.misc; to E.
gE.appendChild(misc);
}
}
}
}
Aggregations