use of org.eclipse.wst.xml.core.internal.contentmodel.CMDocument in project webtools.sourceediting by eclipse.
the class ModelQueryImpl method getCMDocument.
public CMDocument getCMDocument(Element element, String uri) {
CMDocument result = null;
if (modelQueryAssociationProvider instanceof XMLAssociationProvider) {
XMLAssociationProvider xmlAssociationProvider = (XMLAssociationProvider) modelQueryAssociationProvider;
result = xmlAssociationProvider.getCMDocument(element, uri);
}
// ContentModelManager.println("ModelQueryImpl.getCMDocument(" + element.getNodeName() + ", " + uri + ") = " + result);
return result;
}
use of org.eclipse.wst.xml.core.internal.contentmodel.CMDocument in project webtools.sourceediting by eclipse.
the class XMLAssociationProvider method getCorrespondingCMDocument.
protected CMDocument getCorrespondingCMDocument(Node node, boolean getDocumentFromCMNode) {
CMDocument result = null;
try {
Document document = node.getNodeType() == Node.DOCUMENT_NODE ? (Document) node : node.getOwnerDocument();
String[] doctypeInfo = getDoctypeInfo(document);
if (doctypeInfo != null) {
// $NON-NLS-1$
result = getCMDocument(doctypeInfo[0], doctypeInfo[1], "DTD");
} else // TODO... see if there is a way to re-organize to avoid the need for this flag
if (getDocumentFromCMNode) {
CMNode cmNode = getCMNode(node);
if (cmNode != null) {
// todo... add a getCMDocument() methods to CMNode
// for now use the getProperty interface
// $NON-NLS-1$
result = (CMDocument) cmNode.getProperty("CMDocument");
}
}
} catch (Exception e) {
// $NON-NLS-1$
Logger.logException("exception locating CMDocument for " + node, e);
}
return result;
}
use of org.eclipse.wst.xml.core.internal.contentmodel.CMDocument in project webtools.sourceediting by eclipse.
the class XMLAssociationProvider method getCMElementDeclaration.
protected CMElementDeclaration getCMElementDeclaration(Element targetElement, List list, String publicId, String systemId) {
CMElementDeclaration currentED = null;
try {
int listSize = list.size();
for (int i = 0; i < listSize; i++) {
Element element = (Element) list.get(i);
final String nodeName = element.getNodeName();
CMElementDeclaration ed = null;
//
if (currentED != null) {
ed = (CMElementDeclaration) currentED.getLocalElements().getNamedItem(nodeName);
}
if (ed == null) {
// $NON-NLS-1$
CMDocument cmDocument = getCMDocument(publicId, systemId, "XSD");
if (cmDocument != null) {
ed = (CMElementDeclaration) cmDocument.getElements().getNamedItem(nodeName);
}
}
currentED = ed;
}
} catch (Exception e) {
// $NON-NLS-1$
Logger.logException("exception locating element declaration for " + targetElement, e);
}
return currentED;
}
use of org.eclipse.wst.xml.core.internal.contentmodel.CMDocument in project webtools.sourceediting by eclipse.
the class DOMValidator method getFallbackNamepaceURI.
//
// This is a temporary hack!!
//
protected String getFallbackNamepaceURI(CMElementDeclaration ed) {
String fallbackNamepaceURI = null;
// $NON-NLS-1$
CMDocument cmDocument = (CMDocument) ed.getProperty("CMDocument");
if (cmDocument != null) {
// $NON-NLS-1$
fallbackNamepaceURI = (String) cmDocument.getProperty("http://org.eclipse.wst/cm/properties/targetNamespaceURI");
}
return fallbackNamepaceURI;
}
use of org.eclipse.wst.xml.core.internal.contentmodel.CMDocument in project webtools.sourceediting by eclipse.
the class CMDocumentManagerImpl method buildCMDocument.
public synchronized CMDocument buildCMDocument(String publicId, String resolvedURI, String type) {
cmDocumentCache.setStatus(resolvedURI, CMDocumentCache.STATUS_LOADING);
boolean documentCacheable = false;
if (globalCMDocumentCacheEnabled) {
GlobalCacheQueryResponse response = GlobalCMDocumentCache.getInstance().getCMDocument(resolvedURI);
CMDocument cachedCMDocument = response.getCachedCMDocument();
documentCacheable = response.isDocumentCacheable();
if (cachedCMDocument != null) {
cmDocumentCache.putCMDocument(resolvedURI, cachedCMDocument);
return cachedCMDocument;
}
}
CMDocument result = null;
if (resolvedURI != null && resolvedURI.length() > 0) {
// TODO... pass the TYPE thru to the CMDocumentBuilder
result = ContentModelManager.getInstance().createCMDocument(resolvedURI, type);
}
if (result != null) {
// load the annotation files for the document
if (publicId != null) {
AnnotationUtility.loadAnnotationsForGrammar(publicId, result);
}
if (globalCMDocumentCacheEnabled && documentCacheable) {
GlobalCMDocumentCache.getInstance().putCMDocument(resolvedURI, result);
}
cmDocumentCache.putCMDocument(resolvedURI, result);
} else {
cmDocumentCache.setStatus(resolvedURI, CMDocumentCache.STATUS_ERROR);
}
return result;
}
Aggregations