Search in sources :

Example 1 with HTMLCMDocument

use of org.eclipse.wst.html.core.internal.contentmodel.HTMLCMDocument in project webtools.sourceediting by eclipse.

the class HTMLTagsCompletionProposalComputer method isXHTMLNode.

/**
 * Determine if this Document is an XHTML Document. Operates solely off of
 * the Document Type declaration
 */
private static boolean isXHTMLNode(Node node) {
    if (node == null) {
        return false;
    }
    Document doc = null;
    if (node.getNodeType() != Node.DOCUMENT_NODE)
        doc = node.getOwnerDocument();
    else
        doc = ((Document) node);
    if (doc instanceof IDOMDocument) {
        return ((IDOMDocument) doc).isXMLType();
    }
    if (doc instanceof INodeNotifier) {
        ModelQueryAdapter adapter = (ModelQueryAdapter) ((INodeNotifier) doc).getAdapterFor(ModelQueryAdapter.class);
        CMDocument cmdoc = null;
        if (adapter != null && adapter.getModelQuery() != null)
            cmdoc = adapter.getModelQuery().getCorrespondingCMDocument(doc);
        if (cmdoc != null) {
            // model
            if (cmdoc instanceof HTMLCMDocument)
                return false;
            if (cmdoc.supports(HTMLCMProperties.IS_XHTML))
                return Boolean.TRUE.equals(cmdoc.getProperty(HTMLCMProperties.IS_XHTML));
        }
    }
    // this should never be reached
    DocumentType docType = doc.getDoctype();
    // $NON-NLS-1$
    return docType != null && docType.getPublicId() != null && docType.getPublicId().indexOf("-//W3C//DTD XHTML ") == 0;
}
Also used : HTMLCMDocument(org.eclipse.wst.html.core.internal.contentmodel.HTMLCMDocument) CMDocument(org.eclipse.wst.xml.core.internal.contentmodel.CMDocument) ModelQueryAdapter(org.eclipse.wst.xml.core.internal.ssemodelquery.ModelQueryAdapter) HTMLCMDocument(org.eclipse.wst.html.core.internal.contentmodel.HTMLCMDocument) DocumentType(org.w3c.dom.DocumentType) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument) HTMLCMDocument(org.eclipse.wst.html.core.internal.contentmodel.HTMLCMDocument) Document(org.w3c.dom.Document) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument) CMDocument(org.eclipse.wst.xml.core.internal.contentmodel.CMDocument) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) INodeNotifier(org.eclipse.wst.sse.core.internal.provisional.INodeNotifier)

Example 2 with HTMLCMDocument

use of org.eclipse.wst.html.core.internal.contentmodel.HTMLCMDocument in project webtools.sourceediting by eclipse.

the class HTMLContentAssistProcessor method getXHTML.

/**
 * Determine if this Document is an XHTML Document. Oprates solely off of
 * the Document Type declaration
 */
protected boolean getXHTML(Node node) {
    if (node == null)
        return false;
    Document doc = null;
    if (node.getNodeType() != Node.DOCUMENT_NODE)
        doc = node.getOwnerDocument();
    else
        doc = ((Document) node);
    if (doc instanceof IDOMDocument)
        return ((IDOMDocument) doc).isXMLType();
    if (doc instanceof INodeNotifier) {
        ModelQueryAdapter adapter = (ModelQueryAdapter) ((INodeNotifier) doc).getAdapterFor(ModelQueryAdapter.class);
        CMDocument cmdoc = null;
        if (adapter != null && adapter.getModelQuery() != null)
            cmdoc = adapter.getModelQuery().getCorrespondingCMDocument(doc);
        if (cmdoc != null) {
            // model
            if (cmdoc instanceof HTMLCMDocument)
                return false;
            if (cmdoc.supports(HTMLCMProperties.IS_XHTML))
                return Boolean.TRUE.equals(cmdoc.getProperty(HTMLCMProperties.IS_XHTML));
        }
    }
    // this should never be reached
    DocumentType docType = doc.getDoctype();
    // $NON-NLS-1$
    return docType != null && docType.getPublicId() != null && docType.getPublicId().indexOf("-//W3C//DTD XHTML ") == 0;
}
Also used : HTMLCMDocument(org.eclipse.wst.html.core.internal.contentmodel.HTMLCMDocument) CMDocument(org.eclipse.wst.xml.core.internal.contentmodel.CMDocument) ModelQueryAdapter(org.eclipse.wst.xml.core.internal.ssemodelquery.ModelQueryAdapter) HTMLCMDocument(org.eclipse.wst.html.core.internal.contentmodel.HTMLCMDocument) DocumentType(org.w3c.dom.DocumentType) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument) Document(org.w3c.dom.Document) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument) HTMLCMDocument(org.eclipse.wst.html.core.internal.contentmodel.HTMLCMDocument) CMDocument(org.eclipse.wst.xml.core.internal.contentmodel.CMDocument) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument) INodeNotifier(org.eclipse.wst.sse.core.internal.provisional.INodeNotifier)

Aggregations

HTMLCMDocument (org.eclipse.wst.html.core.internal.contentmodel.HTMLCMDocument)2 INodeNotifier (org.eclipse.wst.sse.core.internal.provisional.INodeNotifier)2 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)2 CMDocument (org.eclipse.wst.xml.core.internal.contentmodel.CMDocument)2 IDOMDocument (org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)2 ModelQueryAdapter (org.eclipse.wst.xml.core.internal.ssemodelquery.ModelQueryAdapter)2 Document (org.w3c.dom.Document)2 DocumentType (org.w3c.dom.DocumentType)2