Examples of DocumentFragment


Examples of org.w3c.dom.DocumentFragment

        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();
        Document myDoc = db.newDocument();
       
        Text textNode = myDoc.createTextNode(textNodeValue);
        DocumentFragment docFrag = myDoc.createDocumentFragment();
 
        docFrag.appendChild(textNode);
 
        return new NodeSet(docFrag);
      }
      catch(ParserConfigurationException pce)
      {
View Full Code Here

Examples of org.w3c.dom.DocumentFragment

            break;
        case Node.DOCUMENT_NODE:
            writeDocument((Document)n, writer, repairing);
            break;
        case Node.DOCUMENT_FRAGMENT_NODE: {
            DocumentFragment frag = (DocumentFragment)n;
            Node child = frag.getFirstChild();
            while (child != null) {
                writeNode(child, writer, repairing);
                child = child.getNextSibling();
            }
            break;
View Full Code Here

Examples of org.w3c.dom.DocumentFragment

      document = (Document) this;
    else
      document = getOwnerDocument();
    if (document == null)
      return null;
    DocumentFragment fragment = document.createDocumentFragment();
    if (fragment == null)
      return null;

    if (firstChild == null)
      firstChild = getFirstChild();
    if (lastChild == null)
      lastChild = getLastChild();
    Node nextChild = null;
    for (Node child = firstChild; child != null; child = nextChild) {
      nextChild = child.getNextSibling();
      removeChild(child);
      fragment.appendChild(child);
      if (child == lastChild)
        break;
    }

    return fragment;
View Full Code Here

Examples of org.w3c.dom.DocumentFragment

            W3CDOMStreamWriter writer = new OverlayW3CDOMStreamWriter(soapMessage.getSOAPPart());
            // Replace stax writer with DomStreamWriter
            message.setContent(XMLStreamWriter.class, writer);
            message.setContent(SOAPMessage.class, soapMessage);
           
            DocumentFragment frag = soapMessage.getSOAPPart().createDocumentFragment();
            try {
                Node body = soapMessage.getSOAPBody();
                Node nd = body.getFirstChild();
                while (nd != null) {
                    body.removeChild(nd);
                    frag.appendChild(nd);
                    nd = soapMessage.getSOAPBody().getFirstChild();
                }
                list.set(0, frag);
                //No need to buffer this as we're already a DOM,
                //but only do so if someone hasn't actually configured this
View Full Code Here

Examples of org.w3c.dom.DocumentFragment

        Document doc,
        boolean signObject
    ) throws WSSecurityException {
        Marshaller marshaller = marshallerFactory.getMarshaller(xmlObject);
        Element element = null;
        DocumentFragment frag = doc == null ? null : doc.createDocumentFragment();
        try {
            if (frag != null) {
                String ns = null;
                String nm = null;
                if (doc.getDocumentElement() != null) {
                    ns = doc.getDocumentElement().getNamespaceURI();
                    nm = doc.getDocumentElement().getLocalName();
                }
                while (doc.getFirstChild() != null) {
                    frag.appendChild(doc.removeChild(doc.getFirstChild()));
                }
                if (nm != null) {
                    doc.appendChild(doc.createElementNS(ns, nm));
                }
            }
View Full Code Here

Examples of org.w3c.dom.DocumentFragment

            // System.out.println("Text: " + text);
            SAXSVGDocumentFactory df = new SAXSVGDocumentFactory
                (XMLResourceDescriptor.getXMLParserClassName());
            String uri = ((SVGOMDocument)bridgeContext.getDocument()).
                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());
                sb.append(FRAGMENT_PREFIX);
                sb.append(text);
                sb.append("</svg>");
                String newText = sb.toString();
                try {
                    Document d = df.createDocument
                        (uri, new StringReader(newText));
                    for (Node n = d.getDocumentElement().getFirstChild();
                         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) {
                    SAXDocumentFactory sdf = new SAXDocumentFactory
                        (doc.getImplementation(),
                         XMLResourceDescriptor.getXMLParserClassName());
                    try {
                        Document d = sdf.createDocument
                            (uri, new StringReader(text));
                        result = doc.createDocumentFragment();
                        result.appendChild(doc.importNode(d.getDocumentElement(), true));
                    } catch (Exception ext) {
                        if (userAgent != null)
                            userAgent.displayError(ext);
                    }
                }
View Full Code Here

Examples of org.w3c.dom.DocumentFragment

        this.saveResource = saveResource;
    }

    public synchronized DocumentFragment getXML(String path)
    throws ProcessingException {
        DocumentFragment result = null;
        NodeList list;
        path = this.createPath(path);

        try {
            String[] pathComponents = DOMUtil.buildPathArray(path);
            if (pathComponents == null) {
                //list = DOMUtil.selectNodeList(data, path);
                list = doXPath(path).nodelist();
            } else {
                list = DOMUtil.getNodeListFromPath(data, pathComponents);
            }
        } catch (javax.xml.transform.TransformerException localException) {
            throw new ProcessingException("Transforming exception during selectSingleNode with path: '"+path+"'. Exception: " + localException, localException);
        }

        if (list != null && list.getLength() > 0) {
            Document doc = DOMUtil.createDocument();
            result = doc.createDocumentFragment();

            for(int i = 0; i < list.getLength(); i++) {

                // the found node is either an attribute or an element
                if (list.item(i).getNodeType() == Node.ATTRIBUTE_NODE) {
                    // if it is an attribute simple create a new text node with the value of the attribute
                    result.appendChild(doc.createTextNode(list.item(i).getNodeValue()));
                } else {
                    // now we have an element
                    // copy all children of this element in the resulting tree
                    NodeList childs = list.item(i).getChildNodes();
                    if (childs != null) {
                        for(int m = 0; m < childs.getLength(); m++) {
                            result.appendChild(doc.importNode(childs.item(m), true));
                        }
                    }
                }
            }
        }
View Full Code Here

Examples of org.w3c.dom.DocumentFragment

        }
        Source source = null;
        try {
            source = SourceUtil.getSource(this.loadResource, null, parameters, resolver);
            Document doc = SourceUtil.toDOM(source);
            DocumentFragment df = doc.createDocumentFragment();
            df.appendChild(doc.getDocumentElement());
            this.setXML(path, df);
        } catch (SourceException se) {
            throw SourceUtil.handle(se);
        } finally {
            resolver.release(source);
View Full Code Here

Examples of org.w3c.dom.DocumentFragment

                        ComponentManager   manager)
    throws SAXException, ProcessingException, IOException {
        if (this.saveResource == null) {
            throw new ProcessingException("The context " + this.name + " does not support saving.");
        }
        DocumentFragment frag = this.getXML(path);
        if (frag == null) {
            // create empty fake document
            frag = DOMUtil.createDocument().createDocumentFragment();
        }
View Full Code Here

Examples of org.w3c.dom.DocumentFragment

            // for each node in the node set,
            // then close the repeat tag
            if ((TAG_REPEAT.equals(name)) &&
                (repeatTagDepth==currentTagDepth)) {
                isRecording = false;
                DocumentFragment docFragment = endRecording();

                unrollRepeatTag(docFragment);
                nodeset = null;
                // close the repeat tag
                super.endElement(uri, name, raw);
            }
            // similarly for an itemset tag
            else if ((TAG_ITEMSET.equals(name)) &&
                     (repeatTagDepth==currentTagDepth)) {
                isRecording = false;
                DocumentFragment docFragment = endRecording();

                unrollItemSetTag(docFragment);
                nodeset = null;
            }
            // if within a repeat tag, keep recording
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.