Code example for Document

Methods: createCDATASection, createProcessingInstruction, createTextNode

0
        if (currentNode == null) {
            if (inCDATA) preInfo.add(new CDataInfo(str));
            else         preInfo.add(new TextInfo(str));
        } else { 
            Node n;
            if (inCDATA) n = document.createCDATASection(str);
            else         n = document.createTextNode(str);
            currentNode.appendChild(n);
        } 
    } 
 
    /** 
     * <b>SAX</b>: Implements {@link 
     * org.xml.sax.ContentHandler#characters(char[],int,int)}. 
     */ 
    public void characters(char[] ch, int start, int length)
        throws SAXException { 
        stringBuffer.append(ch, start, length);
        stringContent = true;
    } 
 
 
    /** 
     * <b>SAX</b>: Implements {@link 
     * org.xml.sax.ContentHandler#ignorableWhitespace(char[],int,int)}. 
     */ 
    public void ignorableWhitespace(char[] ch,
                                    int start,
                                    int length)
        throws SAXException { 
        stringBuffer.append(ch, start, length);
        stringContent = true;
    } 
 
    /** 
     * <b>SAX</b>: Implements {@link 
     * org.xml.sax.ContentHandler#processingInstruction(String,String)}. 
     */ 
    public void processingInstruction(String target, String data)
        throws SAXException { 
        if (inDTD)
            return; 
 
        appendStringData(); // Add any collected String Data before PI 
 
        if (currentNode == null)
            preInfo.add(new ProcessingInstructionInfo(target, data));
        else 
            currentNode.appendChild
                (document.createProcessingInstruction(target, data));
    } 
 
    // LexicalHandler ///////////////////////////////////////////////////////// 
 
    /**