Search in sources :

Example 1 with CDATASectionImpl

use of org.apache.harmony.xml.dom.CDATASectionImpl in project XobotOS by xamarin.

the class DocumentBuilderImpl method appendText.

/**
     * @param token the XML pull parser token type, such as XmlPullParser.CDSECT
     *      or XmlPullParser.ENTITY_REF.
     */
private void appendText(DocumentImpl document, Node parent, int token, String text) {
    // Ignore empty runs.
    if (text.isEmpty()) {
        return;
    }
    // Merge with any previous text node if possible.
    if (coalescing || token != XmlPullParser.CDSECT) {
        Node lastChild = parent.getLastChild();
        if (lastChild != null && lastChild.getNodeType() == Node.TEXT_NODE) {
            Text textNode = (Text) lastChild;
            textNode.appendData(text);
            return;
        }
    }
    // Okay, we really do need a new text node
    parent.appendChild(token == XmlPullParser.CDSECT ? new CDATASectionImpl(document, text) : new TextImpl(document, text));
}
Also used : Node(org.w3c.dom.Node) Text(org.w3c.dom.Text) CDATASectionImpl(org.apache.harmony.xml.dom.CDATASectionImpl) TextImpl(org.apache.harmony.xml.dom.TextImpl)

Example 2 with CDATASectionImpl

use of org.apache.harmony.xml.dom.CDATASectionImpl in project j2objc by google.

the class DocumentBuilderImpl method appendText.

/**
     * @param token the XML pull parser token type, such as XmlPullParser.CDSECT
     *      or XmlPullParser.ENTITY_REF.
     */
private void appendText(DocumentImpl document, Node parent, int token, String text) {
    // Ignore empty runs.
    if (text.isEmpty()) {
        return;
    }
    // Merge with any previous text node if possible.
    if (coalescing || token != XmlPullParser.CDSECT) {
        Node lastChild = parent.getLastChild();
        if (lastChild != null && lastChild.getNodeType() == Node.TEXT_NODE) {
            Text textNode = (Text) lastChild;
            textNode.appendData(text);
            return;
        }
    }
    // Okay, we really do need a new text node
    parent.appendChild(token == XmlPullParser.CDSECT ? new CDATASectionImpl(document, text) : new TextImpl(document, text));
}
Also used : Node(org.w3c.dom.Node) Text(org.w3c.dom.Text) CDATASectionImpl(org.apache.harmony.xml.dom.CDATASectionImpl) TextImpl(org.apache.harmony.xml.dom.TextImpl)

Example 3 with CDATASectionImpl

use of org.apache.harmony.xml.dom.CDATASectionImpl in project robovm by robovm.

the class DocumentBuilderImpl method appendText.

/**
     * @param token the XML pull parser token type, such as XmlPullParser.CDSECT
     *      or XmlPullParser.ENTITY_REF.
     */
private void appendText(DocumentImpl document, Node parent, int token, String text) {
    // Ignore empty runs.
    if (text.isEmpty()) {
        return;
    }
    // Merge with any previous text node if possible.
    if (coalescing || token != XmlPullParser.CDSECT) {
        Node lastChild = parent.getLastChild();
        if (lastChild != null && lastChild.getNodeType() == Node.TEXT_NODE) {
            Text textNode = (Text) lastChild;
            textNode.appendData(text);
            return;
        }
    }
    // Okay, we really do need a new text node
    parent.appendChild(token == XmlPullParser.CDSECT ? new CDATASectionImpl(document, text) : new TextImpl(document, text));
}
Also used : Node(org.w3c.dom.Node) Text(org.w3c.dom.Text) CDATASectionImpl(org.apache.harmony.xml.dom.CDATASectionImpl) TextImpl(org.apache.harmony.xml.dom.TextImpl)

Aggregations

CDATASectionImpl (org.apache.harmony.xml.dom.CDATASectionImpl)3 TextImpl (org.apache.harmony.xml.dom.TextImpl)3 Node (org.w3c.dom.Node)3 Text (org.w3c.dom.Text)3