use of org.eclipse.wst.xml.core.internal.contentmodel.CMAnyElement in project webtools.sourceediting by eclipse.
the class DOMContentBuilderImpl method visitCMAnyElement.
public void visitCMAnyElement(CMAnyElement anyElement) {
// ingnore buildPolicy for ANY elements... only create elements if
// absolutely needed
//
int forcedMin = alwaysVisit ? 1 : 0;
int min = Math.max(anyElement.getMinOccur(), forcedMin);
alwaysVisit = false;
String uri = anyElement.getNamespaceURI();
// $NON-NLS-1$
String targetNSProperty = "http://org.eclipse.wst/cm/properties/targetNamespaceURI";
// $NON-NLS-1$
CMDocument parentCMDocument = (CMDocument) anyElement.getProperty("CMDocument");
CMElementDeclaration ed = null;
// //$NON-NLS-1$
if (parentCMDocument != null) {
if (// $NON-NLS-1$
uri == null || uri.startsWith("##") || uri.equals(parentCMDocument.getProperty(targetNSProperty))) {
ed = getSuitableElement(getParentCMElementDeclaration(), parentCMDocument);
}
}
if (// $NON-NLS-1$
ed == null && externalCMDocumentSupport != null && uri != null && !uri.startsWith("##") && currentParent instanceof Element) {
CMDocument externalCMDocument = externalCMDocumentSupport.getCMDocument((Element) currentParent, uri);
if (externalCMDocument != null) {
ed = getSuitableElement(null, externalCMDocument);
}
}
for (int i = 1; i <= min; i++) {
if (ed != null) {
visitCMElementDeclaration(ed);
} else {
// $NON-NLS-1$
Element element = document.createElement("ANY-ELEMENT");
linkNode(element);
}
}
}
use of org.eclipse.wst.xml.core.internal.contentmodel.CMAnyElement in project webtools.sourceediting by eclipse.
the class InferredGrammarFactory method createCMContent.
public void createCMContent(CMDocument parentCMDocument, CMElementDeclaration parentEd, CMDocument childCMDocument, CMElementDeclaration childEd, boolean isLocal, String uri) {
// add element to the parent's content
// consider all content to be of the form (A | B | C)*
//
CMGroupImpl group = (CMGroupImpl) parentEd.getContent();
CMNodeListImpl groupChildNodeList = (CMNodeListImpl) group.getChildNodes();
if (parentCMDocument == childCMDocument) {
if (!groupChildNodeList.contains(childEd)) {
groupChildNodeList.add(childEd);
}
if (isLocal) {
CMNamedNodeMapImpl localElementMap = (CMNamedNodeMapImpl) parentEd.getLocalElements();
localElementMap.put(childEd);
}
} else {
CMAnyElement cmAnyElement = lookupOrCreateCMAnyElement((CMDocumentImpl) parentCMDocument, uri);
if (!groupChildNodeList.contains(cmAnyElement)) {
groupChildNodeList.add(cmAnyElement);
}
}
}
Aggregations