Search in sources :

Example 6 with ISourceGenerator

use of org.eclipse.wst.xml.core.internal.provisional.document.ISourceGenerator in project webtools.sourceediting by eclipse.

the class BasicCommentElementHandler method generateEndTagContent.

public String generateEndTagContent(IDOMElement element) {
    if (isEmpty) {
        return null;
    }
    ISourceGenerator generator = element.getModel().getGenerator();
    StringBuffer buffer = new StringBuffer();
    // $NON-NLS-1$
    buffer.append(" /");
    String tagName = generator.generateTagName(element);
    if (tagName != null) {
        buffer.append(tagName);
    }
    buffer.append(' ');
    return buffer.toString();
}
Also used : ISourceGenerator(org.eclipse.wst.xml.core.internal.provisional.document.ISourceGenerator)

Example 7 with ISourceGenerator

use of org.eclipse.wst.xml.core.internal.provisional.document.ISourceGenerator in project webtools.sourceediting by eclipse.

the class BasicCommentElementHandler method generateStartTagContent.

public String generateStartTagContent(IDOMElement element) {
    ISourceGenerator generator = element.getModel().getGenerator();
    StringBuffer buffer = new StringBuffer();
    buffer.append(' ');
    String tagName = generator.generateTagName(element);
    if (tagName != null) {
        buffer.append(tagName);
    }
    NamedNodeMap attributes = element.getAttributes();
    int length = attributes.getLength();
    for (int i = 0; i < length; i++) {
        Attr attr = (Attr) attributes.item(i);
        if (attr == null) {
            continue;
        }
        buffer.append(' ');
        String attrName = generator.generateAttrName(attr);
        if (attrName != null) {
            buffer.append(attrName);
        }
        String attrValue = generator.generateAttrValue(attr);
        if (attrValue != null) {
            // attr name only for HTML boolean and JSP
            buffer.append('=');
            buffer.append(attrValue);
        }
    }
    buffer.append(' ');
    return buffer.toString();
}
Also used : NamedNodeMap(org.w3c.dom.NamedNodeMap) ISourceGenerator(org.eclipse.wst.xml.core.internal.provisional.document.ISourceGenerator) IDOMAttr(org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr) Attr(org.w3c.dom.Attr)

Aggregations

ISourceGenerator (org.eclipse.wst.xml.core.internal.provisional.document.ISourceGenerator)7 NamedNodeMap (org.w3c.dom.NamedNodeMap)5 CMNamedNodeMap (org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap)4 IDOMModel (org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel)4 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)3 IDOMAttr (org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr)3 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)2 Attr (org.w3c.dom.Attr)2 BadLocationException (org.eclipse.jface.text.BadLocationException)1 IStructuredDocumentRegion (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)1 ITextRegion (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion)1 ITextRegionList (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList)1 CMAttributeDeclaration (org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration)1 CMElementDeclaration (org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration)1 AttrImpl (org.eclipse.wst.xml.core.internal.document.AttrImpl)1 IDOMElement (org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement)1 ModelQueryAdapter (org.eclipse.wst.xml.core.internal.ssemodelquery.ModelQueryAdapter)1 Element (org.w3c.dom.Element)1