Package org.w3c.dom

Examples of org.w3c.dom.DocumentFragment.appendChild()


      Document newDoc = builder.parse(new ByteArrayInputStream(markupBytes));
   
      DocumentFragment fragment = newDoc.createDocumentFragment();
     
      // add the document's root element to the fragment
      fragment.appendChild(newDoc.getDocumentElement());
     
      return fragment;
    }
    catch (SAXException se)
    {     
View Full Code Here


    }

    public void testFragment() throws Exception {
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        DocumentFragment fragment = dom.getOwnerDocument().createDocumentFragment();
        fragment.appendChild(dom.getOwnerDocument().getDocumentElement());
        TextWriter.write(fragment, out);
        assertEquals(FRAGMENT, out.toString());
    }
}
View Full Code Here

                getURLObject().toString();
            DocumentFragment result = null;
            try {
                Document d = df.createDocument(uri, new StringReader(text));
                result = doc.createDocumentFragment();
                result.appendChild(doc.importNode(d.getDocumentElement(),
                                                  true));
            } catch (Exception ex) {
                StringBuffer sb = new StringBuffer(text.length() +
                                                   FRAGMENT_PREFIX.length() +
                                                   "</svg>".length());
View Full Code Here

                         n != null;
                         n = n.getNextSibling()) {
                        if (n.getNodeType() == n.ELEMENT_NODE) {
                            n = doc.importNode(n, true);
                            result = doc.createDocumentFragment();
                            result.appendChild(n);
                            break;
                        }
                    }
                } catch (Exception exc) {
                    // !!! TODO: warning
View Full Code Here

                getURLObject().toString();
            DocumentFragment result = null;
            try {
                Document d = df.createDocument(uri, new StringReader(text));
                result = doc.createDocumentFragment();
                result.appendChild(doc.importNode(d.getDocumentElement(),
                                                  true));
            } catch (Exception ex) {
                StringBuffer sb = new StringBuffer(text.length() +
                                                   FRAGMENT_PREFIX.length() +
                                                   "</svg>".length());
View Full Code Here

                         n = n.getNextSibling()) {
                        System.out.println("We screwed up");
                        if (n.getNodeType() == n.ELEMENT_NODE) {
                            n = doc.importNode(n, true);
                            result = doc.createDocumentFragment();
                            result.appendChild(n);
                            break;
                        }
                    }
                } catch (Exception exc) {
                    // !!! TODO: warning
View Full Code Here

                // Nothing is partially selected, so collapse to start point
                collapse( true );
            }
            if ( how==DELETE_CONTENTS)
                return null;
            frag.appendChild( fDocument.createTextNode(sub) );
            return frag;
        }

        // Copy nodes between the start/end offsets.
        Node n = getSelectedNode( fStartContainer, fStartOffset );
View Full Code Here

        while( cnt > 0 )
        {
            Node sibling = n.getNextSibling();
            Node xferNode = traverseFullySelected( n, how );
            if ( frag!=null )
                frag.appendChild( xferNode );
            --cnt;
            n = sibling;
        }

        // Nothing is partially selected, so collapse to start point
View Full Code Here

        DocumentFragment frag = null;
        if ( how!=DELETE_CONTENTS)
            frag = fDocument.createDocumentFragment();
        Node n = traverseRightBoundary( endAncestor, how );
        if ( frag!=null )
            frag.appendChild( n );

        int endIdx = indexOf( endAncestor, fStartContainer );
        int cnt = endIdx - fStartOffset;
        if ( cnt <=0 )
        {
View Full Code Here

        DocumentFragment frag = null;
        if ( how!=DELETE_CONTENTS)
            frag = fDocument.createDocumentFragment();
        Node n = traverseLeftBoundary( startAncestor, how );
        if ( frag!=null )
            frag.appendChild( n );
        int startIdx = indexOf( startAncestor, fEndContainer );
        ++startIdx;  // Because we already traversed it....

        int cnt = fEndOffset - startIdx;
        n = startAncestor.getNextSibling();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.