use of org.eclipse.wst.xml.core.internal.contentmodel.CMContent in project webtools.sourceediting by eclipse.
the class ModelQueryTester method testDTDLoadFromSystemID_2.
/**
* A short test to ensure that a DTD, the XHTML 1.0 Transitional one, can
* be loaded from a system reference.
*
* Note: May require a functioning network connection for the references
* to be resolved properly.
* @throws IOException
*/
public void testDTDLoadFromSystemID_2() throws IOException {
if (testShippedDTDLookup) {
URL installationPath = Platform.getBundle(JSPUITestsPlugin.ID).getEntry("/");
String diskLocation = null;
diskLocation = FileLocator.resolve(installationPath).toExternalForm();
assertTrue("failed to resolve plugin install path", diskLocation != null);
setUpXML();
String content = "<?xml version=\"1.0\"?><!DOCTYPE html SYSTEM " + diskLocation + "testfiles/XHTML/xhtml1-transitional.dtd\"" + "><html></html>";
fModel.getStructuredDocument().set(content);
CMDocumentManager documentManagaer = fModelQuery.getCMDocumentManager();
documentManagaer.setPropertyEnabled(CMDocumentManager.PROPERTY_ASYNC_LOAD, false);
documentManagaer.setPropertyEnabled(CMDocumentManager.PROPERTY_AUTO_LOAD, true);
// see defect 282429
CMElementDeclaration htmlDecl = (CMElementDeclaration) fModelQuery.getCMNode((Node) fModel.getIndexedRegion(content.length() - 2));
assertTrue("xhtml1-transitional.dtd not loaded", htmlDecl != null);
// 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().equals(HTML40Namespace.ElementName.HEAD.toLowerCase()));
assertTrue("child order (BODY second)", childList.item(1).getNodeName().equals(HTML40Namespace.ElementName.BODY.toLowerCase()));
}
}
use of org.eclipse.wst.xml.core.internal.contentmodel.CMContent in project webtools.sourceediting by eclipse.
the class HMQUtil method gatherInclusions.
private static Collection gatherInclusions(Collection ancestors) {
Vector inclusions = new Vector();
Iterator iter = ancestors.iterator();
while (iter.hasNext()) {
CMElementDeclaration decl = (CMElementDeclaration) iter.next();
if (decl.supports(HTMLCMProperties.INCLUSION)) {
CMContent inclusion = (CMContent) decl.getProperty(HTMLCMProperties.INCLUSION);
if (inclusion != null)
inclusions.add(inclusion);
}
}
return inclusions;
}
Aggregations