Search in sources :

Example 1 with HTMLDocumentTypeEntry

use of org.eclipse.wst.html.core.internal.document.HTMLDocumentTypeEntry in project webtools.sourceediting by eclipse.

the class StructuredAutoEditStrategyHTML method isXHTML.

/**
 * Is the node part of an XHTML document
 * @param node
 * @return
 */
private boolean isXHTML(Node node) {
    Document doc = node.getOwnerDocument();
    if (!(doc instanceof IDOMDocument))
        return false;
    String typeid = ((IDOMDocument) doc).getDocumentTypeId();
    if (typeid != null) {
        HTMLDocumentTypeEntry entry = HTMLDocumentTypeRegistry.getInstance().getEntry(typeid);
        return (entry != null && entry.isXMLType());
    }
    return false;
}
Also used : HTMLDocumentTypeEntry(org.eclipse.wst.html.core.internal.document.HTMLDocumentTypeEntry) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument) IDocument(org.eclipse.jface.text.IDocument) Document(org.w3c.dom.Document) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)

Example 2 with HTMLDocumentTypeEntry

use of org.eclipse.wst.html.core.internal.document.HTMLDocumentTypeEntry in project webtools.sourceediting by eclipse.

the class HTMLModelQueryCMProvider method getCorrespondingCMDocument.

/**
 * Returns the CMDocument that corresponds to the DOM Node. or null if no
 * CMDocument is appropriate for the DOM Node.
 */
public CMDocument getCorrespondingCMDocument(Node node) {
    IDOMDocument owner = getOwnerXMLDocument(node);
    if (owner == null)
        return null;
    String pid = getPublicId(owner);
    // no PID, always return the currently-supported HTML version
    if (pid == null || "".equals(pid)) {
        return staticHTML5;
    }
    HTMLDocumentTypeEntry entry = doctypeRegistry.getEntry(pid);
    if (entry == null)
        return staticHTML;
    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=151000 - use internal content model
    if (entry.useInternalModel()) {
        if (pid != null && pid.equals(HTMLDocumentTypeRegistry.CHTML_PUBLIC_ID)) {
            return staticCHTML;
        }
        return staticHTML;
    }
    pid = entry.getPublicId();
    String sid = entry.getSystemId();
    CMDocument dtdcm = xhtmlassoc.getXHTMLCMDocument(pid, sid);
    if (dtdcm == null) {
        if (pid != null && pid.equals(HTMLDocumentTypeRegistry.CHTML_PUBLIC_ID)) {
            return staticCHTML;
        }
        return staticHTML;
    }
    String grammarURI = xhtmlassoc.getCachedGrammerURI();
    CMDocument buddycm = (CMDocument) buddyCache.get(grammarURI);
    if (buddycm != null)
        return buddycm;
    buddycm = new CMDocumentForBuddySystem(dtdcm, entry.isXMLType());
    buddyCache.put(grammarURI, buddycm);
    return buddycm;
}
Also used : CMDocument(org.eclipse.wst.xml.core.internal.contentmodel.CMDocument) HTMLDocumentTypeEntry(org.eclipse.wst.html.core.internal.document.HTMLDocumentTypeEntry) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)

Example 3 with HTMLDocumentTypeEntry

use of org.eclipse.wst.html.core.internal.document.HTMLDocumentTypeEntry in project webtools.sourceediting by eclipse.

the class SyntaxValidator method getInfo.

private void getInfo(ElementInfo info) {
    info.decl = CMUtil.getDeclaration(info.target);
    info.startTag = info.target.getStartStructuredDocumentRegion();
    info.endTag = info.target.getEndStructuredDocumentRegion();
    Document doc = info.target.getOwnerDocument();
    if (!(doc instanceof IDOMDocument))
        return;
    String typeid = ((IDOMDocument) doc).getDocumentTypeId();
    if (typeid != null) {
        if (typeid.trim().length() != 0) {
            HTMLDocumentTypeEntry entry = HTMLDocumentTypeRegistry.getInstance().getEntry(typeid);
            info.isXHTML = (entry != null && entry.isXMLType());
        } else {
            info.isXHTML = getXMLTarget(doc);
            info.isXHTML5 = info.isXHTML;
        }
    }
}
Also used : HTMLDocumentTypeEntry(org.eclipse.wst.html.core.internal.document.HTMLDocumentTypeEntry) 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) IStructuredDocument(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)

Example 4 with HTMLDocumentTypeEntry

use of org.eclipse.wst.html.core.internal.document.HTMLDocumentTypeEntry in project webtools.sourceediting by eclipse.

the class ContentSettingsRegistry method getSystemIdFrom.

public static String getSystemIdFrom(String publicId) {
    if (publicId == null || publicId.length() == 0)
        return null;
    HTMLDocumentTypeRegistry reg = HTMLDocumentTypeRegistry.getInstance();
    Enumeration e = reg.getEntries();
    while (e.hasMoreElements()) {
        HTMLDocumentTypeEntry entry = (HTMLDocumentTypeEntry) e.nextElement();
        if (entry.getPublicId().equals(publicId))
            return entry.getSystemId();
    }
    return null;
}
Also used : Enumeration(java.util.Enumeration) HTMLDocumentTypeEntry(org.eclipse.wst.html.core.internal.document.HTMLDocumentTypeEntry) HTMLDocumentTypeRegistry(org.eclipse.wst.html.core.internal.document.HTMLDocumentTypeRegistry)

Example 5 with HTMLDocumentTypeEntry

use of org.eclipse.wst.html.core.internal.document.HTMLDocumentTypeEntry in project webtools.sourceediting by eclipse.

the class WebContentSettingsPropertyPage method getSystemIdFrom.

private String getSystemIdFrom(String publicId) {
    if (publicId == null || publicId.length() == 0)
        return null;
    HTMLDocumentTypeRegistry reg = HTMLDocumentTypeRegistry.getInstance();
    Enumeration e = reg.getEntries();
    while (e.hasMoreElements()) {
        HTMLDocumentTypeEntry entry = (HTMLDocumentTypeEntry) e.nextElement();
        if (entry.getPublicId().equals(publicId))
            return entry.getSystemId();
    }
    return null;
}
Also used : Enumeration(java.util.Enumeration) HTMLDocumentTypeEntry(org.eclipse.wst.html.core.internal.document.HTMLDocumentTypeEntry) HTMLDocumentTypeRegistry(org.eclipse.wst.html.core.internal.document.HTMLDocumentTypeRegistry)

Aggregations

HTMLDocumentTypeEntry (org.eclipse.wst.html.core.internal.document.HTMLDocumentTypeEntry)8 Enumeration (java.util.Enumeration)4 HTMLDocumentTypeRegistry (org.eclipse.wst.html.core.internal.document.HTMLDocumentTypeRegistry)4 IDOMDocument (org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)3 Document (org.w3c.dom.Document)2 ArrayList (java.util.ArrayList)1 IDocument (org.eclipse.jface.text.IDocument)1 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)1 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)1 CustomCompletionProposal (org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal)1 CMDocument (org.eclipse.wst.xml.core.internal.contentmodel.CMDocument)1