Search in sources :

Example 11 with CMDocument

use of org.eclipse.wst.xml.core.internal.contentmodel.CMDocument in project webtools.sourceediting by eclipse.

the class DOMNamespaceHelper method computeName.

public static String computeName(CMNode cmNode, Node parent, String prefix, NamespaceTable namespaceTable) {
    String result = cmNode.getNodeName();
    // 
    if (getPrefix(result) == null) {
        // $NON-NLS-1$
        String qualification = (String) cmNode.getProperty("http://org.eclipse.wst/cm/properties/nsPrefixQualification");
        // 
        if (// $NON-NLS-1$
        qualification != null && qualification.equals("qualified")) {
            if (prefix == null) {
                // todo... add getCMDocument() method to CMNode
                // for now use this getProperty() hack
                // $NON-NLS-1$
                CMDocument cmDocument = (CMDocument) cmNode.getProperty("CMDocument");
                if (cmDocument != null) {
                    // $NON-NLS-1$
                    String namespaceURI = (String) cmDocument.getProperty("http://org.eclipse.wst/cm/properties/targetNamespaceURI");
                    if (namespaceURI != null) {
                        // 
                        if (namespaceTable == null) {
                            Document document = parent.getNodeType() == Node.DOCUMENT_NODE ? (Document) parent : parent.getOwnerDocument();
                            namespaceTable = new NamespaceTable(document);
                            if (parent instanceof Element) {
                                namespaceTable.addElementLineage((Element) parent);
                            }
                        }
                        prefix = namespaceTable.getPrefixForURI(namespaceURI);
                    }
                }
            }
            if (prefix != null && prefix.length() > 0) {
                // $NON-NLS-1$
                result = prefix + ":" + result;
            }
        }
    }
    return result;
}
Also used : CMDocument(org.eclipse.wst.xml.core.internal.contentmodel.CMDocument) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document) CMDocument(org.eclipse.wst.xml.core.internal.contentmodel.CMDocument)

Example 12 with CMDocument

use of org.eclipse.wst.xml.core.internal.contentmodel.CMDocument in project webtools.sourceediting by eclipse.

the class InferredGrammarFactory method debugPrint.

public void debugPrint(Collection collection) {
    for (Iterator iter = collection.iterator(); iter.hasNext(); ) {
        CMDocument cmDocument = (CMDocument) iter.next();
        // $NON-NLS-1$
        System.out.println("-----------------------------------------------");
        // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        System.out.println("cmDocument (" + cmDocument.getProperty("http://org.eclipse.wst/cm/properties/targetNamespaceURI") + ")");
        CMNamedNodeMapImpl elementMap = (CMNamedNodeMapImpl) cmDocument.getElements();
        int size = elementMap.getLength();
        for (int i = 0; i < size; i++) {
            CMElementDeclaration ed = (CMElementDeclaration) elementMap.item(i);
            CMDescriptionBuilder builder = new CMDescriptionBuilder();
            // $NON-NLS-1$ //$NON-NLS-2$
            System.out.println("  ELEMENT " + ed.getNodeName() + " = " + builder.buildDescription(ed));
        }
    }
}
Also used : CMDocument(org.eclipse.wst.xml.core.internal.contentmodel.CMDocument) CMNamedNodeMapImpl(org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl) CMElementDeclaration(org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration) Iterator(java.util.Iterator) CMDescriptionBuilder(org.eclipse.wst.xml.core.internal.contentmodel.util.CMDescriptionBuilder)

Example 13 with CMDocument

use of org.eclipse.wst.xml.core.internal.contentmodel.CMDocument in project webtools.sourceediting by eclipse.

the class CMDocumentFactoryTLD method buildCMDocumentFromJar.

/**
 * Builds a CMDocument
 *
 * @param jarFileName -
 *            the name of the containing JAR file
 * @param contentFileName -
 *            the path within the JAR for a valid taglib descriptor
 */
protected CMDocument buildCMDocumentFromJar(String jarFileName, String contentFileName) {
    // load the taglib descriptor file
    DocumentProvider provider = new DocumentProvider();
    provider.setValidating(false);
    provider.setBaseReference(jarFileName);
    provider.setRootElementName(JSP11TLDNames.TAGLIB);
    provider.setJarFileName(jarFileName);
    provider.setFileName(contentFileName);
    // $NON-NLS-1$ //$NON-NLS-2$
    CMDocument document = loadDocument("jar:file://" + jarFileName + "!" + contentFileName, provider.getRootElement());
    // 8.4.1
    return document;
}
Also used : CMDocument(org.eclipse.wst.xml.core.internal.contentmodel.CMDocument) DocumentProvider(org.eclipse.jst.jsp.core.internal.util.DocumentProvider)

Example 14 with CMDocument

use of org.eclipse.wst.xml.core.internal.contentmodel.CMDocument in project webtools.sourceediting by eclipse.

the class CSSProposalGeneratorForHTMLTag method setupHTMLTags.

/**
 */
private static String[] setupHTMLTags() {
    CMDocument cmdoc = HTMLCMDocumentFactory.getCMDocument(CMDocType.HTML_DOC_TYPE);
    CMNamedNodeMap elements = cmdoc.getElements();
    Vector names = new Vector();
    int nElements = elements.getLength();
    for (int i = 0; i < nElements; i++) {
        CMElementDeclaration edec = (CMElementDeclaration) elements.item(i);
        if (isAttrDefined(edec, HTML40Namespace.ATTR_NAME_STYLE)) {
            names.add(edec.getElementName());
        }
    }
    Collections.sort(names);
    String[] tags = new String[names.size()];
    Iterator iNames = names.iterator();
    for (int i = 0; iNames.hasNext(); i++) {
        tags[i] = (String) iNames.next();
    }
    return tags;
}
Also used : CMDocument(org.eclipse.wst.xml.core.internal.contentmodel.CMDocument) CMElementDeclaration(org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration) Iterator(java.util.Iterator) CMNamedNodeMap(org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap) Vector(java.util.Vector)

Example 15 with CMDocument

use of org.eclipse.wst.xml.core.internal.contentmodel.CMDocument in project webtools.sourceediting by eclipse.

the class DTDImpl method buildCMDocument.

public static CMDocument buildCMDocument(String uri) {
    DTDFile dtdFile = buildDTDModel(uri);
    CMDocument cmDocument = (CMDocument) getAdapter(dtdFile);
    return cmDocument;
}
Also used : CMDocument(org.eclipse.wst.xml.core.internal.contentmodel.CMDocument) DTDFile(org.eclipse.wst.dtd.core.internal.emf.DTDFile)

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