Search in sources :

Example 56 with CMDocument

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;
}
Also used : CMDocument(org.eclipse.wst.xml.core.internal.contentmodel.CMDocument)

Example 57 with CMDocument

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;
}
Also used : CMDocument(org.eclipse.wst.xml.core.internal.contentmodel.CMDocument) CMNode(org.eclipse.wst.xml.core.internal.contentmodel.CMNode) Document(org.w3c.dom.Document) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument) CMDocument(org.eclipse.wst.xml.core.internal.contentmodel.CMDocument)

Example 58 with CMDocument

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;
}
Also used : CMDocument(org.eclipse.wst.xml.core.internal.contentmodel.CMDocument) CMElementDeclaration(org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration) Element(org.w3c.dom.Element)

Example 59 with CMDocument

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;
}
Also used : CMDocument(org.eclipse.wst.xml.core.internal.contentmodel.CMDocument)

Example 60 with CMDocument

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;
}
Also used : CMDocument(org.eclipse.wst.xml.core.internal.contentmodel.CMDocument) GlobalCacheQueryResponse(org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.GlobalCMDocumentCache.GlobalCacheQueryResponse)

Aggregations

CMDocument (org.eclipse.wst.xml.core.internal.contentmodel.CMDocument)83 CMElementDeclaration (org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration)33 CMNamedNodeMap (org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap)26 CMNode (org.eclipse.wst.xml.core.internal.contentmodel.CMNode)20 List (java.util.List)15 ModelQuery (org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery)14 Document (org.w3c.dom.Document)12 Element (org.w3c.dom.Element)11 ArrayList (java.util.ArrayList)10 Path (org.eclipse.core.runtime.Path)8 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)8 JSPCMDocument (org.eclipse.wst.html.core.internal.contentmodel.JSPCMDocument)7 ITextRegionList (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList)7 IDOMDocument (org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)7 URL (java.net.URL)6 TLDCMDocumentManager (org.eclipse.jst.jsp.core.internal.contentmodel.tld.TLDCMDocumentManager)6 Node (org.w3c.dom.Node)6 NodeList (org.w3c.dom.NodeList)6 Iterator (java.util.Iterator)5 IStructuredDocumentRegion (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)5