FileDocCategorySizeDatePackage
DOMUtils.javaAPI DocApache Ant 1.704792Wed Dec 13 06:16:20 GMT 2006org.apache.tools.ant.util

DOMUtils

public class DOMUtils extends Object
Some utility methods for common tasks when building DOM trees in memory.

In this documentation <a> means an {@link org.w3c.dom.Element Element} instance with name a.

since
Ant 1.6.3

Fields Summary
Constructors Summary
Methods Summary
public static voidappendCDATA(org.w3c.dom.Element parent, java.lang.String content)
Adds a nested CDATA section.

This means

appendCDATA(<a>, "b")
creates
<a><[!CDATA[b]]></a>

param
parent element that will receive the new element as child.
param
content text content.
since
Ant 1.6.3

        Document doc = parent.getOwnerDocument();
        CDATASection c = doc.createCDATASection(content);
        parent.appendChild(c);
    
public static voidappendCDATAElement(org.w3c.dom.Element parent, java.lang.String name, java.lang.String content)
Adds a nested CDATA section in a new child element.

This means

appendCDATAElement(<a>, "b", "c")
creates
<a>
<b><![CDATA[c]]></b>
</a>

param
parent element that will receive the new element as child.
param
name of the child element.
param
content text content.
since
Ant 1.6.3

        Element e = createChildElement(parent, name);
        appendCDATA(e, content);
    
public static voidappendText(org.w3c.dom.Element parent, java.lang.String content)
Adds nested text.

This means

appendText(<a>, "b")
creates
<a>b</a>

param
parent element that will receive the new element as child.
param
content text content.
since
Ant 1.6.3

        Document doc = parent.getOwnerDocument();
        Text t = doc.createTextNode(content);
        parent.appendChild(t);
    
public static voidappendTextElement(org.w3c.dom.Element parent, java.lang.String name, java.lang.String content)
Adds nested text in a new child element.

This means

appendTextElement(<a>, "b", "c")
creates
<a>
<b>c</b>
</a>

param
parent element that will receive the new element as child.
param
name of the child element.
param
content text content.
since
Ant 1.6.3

        Element e = createChildElement(parent, name);
        appendText(e, content);
    
public static org.w3c.dom.ElementcreateChildElement(org.w3c.dom.Element parent, java.lang.String name)
Creates a named Element and appends it to the given element, returns it.

This means

createChildElement(<a>, "b")
creates
<a>
<b/>
</a>
and returns <b>.

param
parent element that will receive the new element as child.
param
name name of the new element.
return
the new element.
since
Ant 1.6.3

        Document doc = parent.getOwnerDocument();
        Element e = doc.createElement(name);
        parent.appendChild(e);
        return e;
    
public static org.w3c.dom.DocumentnewDocument()
Get a new Document instance,

return
the document.
since
Ant 1.6.3

        return JAXPUtils.getDocumentBuilder().newDocument();