Search in sources :

Example 46 with DocumentFragment

use of org.w3c.dom.DocumentFragment in project cxf by apache.

the class EncoderDecoder10AImpl method encodeSequenceAcknowledgement.

public Element encodeSequenceAcknowledgement(SequenceAcknowledgement ack) throws JAXBException {
    DocumentFragment doc = DOMUtils.getEmptyDocument().createDocumentFragment();
    Marshaller marshaller = getContext().createMarshaller();
    marshaller.marshal(VersionTransformer.convert200502wsa15(ack), doc);
    return (Element) doc.getFirstChild();
}
Also used : Marshaller(javax.xml.bind.Marshaller) JAXBElement(javax.xml.bind.JAXBElement) Element(org.w3c.dom.Element) DocumentFragment(org.w3c.dom.DocumentFragment)

Example 47 with DocumentFragment

use of org.w3c.dom.DocumentFragment in project cxf by apache.

the class EncoderDecoder10AImpl method encodeIdentifier.

public Element encodeIdentifier(Identifier id) throws JAXBException {
    DocumentFragment doc = DOMUtils.getEmptyDocument().createDocumentFragment();
    Marshaller marshaller = getContext().createMarshaller();
    marshaller.marshal(VersionTransformer.convert200502wsa15(id), doc);
    return (Element) doc.getFirstChild();
}
Also used : Marshaller(javax.xml.bind.Marshaller) JAXBElement(javax.xml.bind.JAXBElement) Element(org.w3c.dom.Element) DocumentFragment(org.w3c.dom.DocumentFragment)

Example 48 with DocumentFragment

use of org.w3c.dom.DocumentFragment in project cxf by apache.

the class EncoderDecoder11Impl method encodeIdentifier.

public Element encodeIdentifier(Identifier id) throws JAXBException {
    DocumentFragment doc = DOMUtils.getEmptyDocument().createDocumentFragment();
    Marshaller marshaller = getContext().createMarshaller();
    marshaller.marshal(id, doc);
    return (Element) doc.getFirstChild();
}
Also used : Marshaller(javax.xml.bind.Marshaller) JAXBElement(javax.xml.bind.JAXBElement) Element(org.w3c.dom.Element) DocumentFragment(org.w3c.dom.DocumentFragment)

Example 49 with DocumentFragment

use of org.w3c.dom.DocumentFragment in project nutch by apache.

the class HtmlParser method parseNeko.

private DocumentFragment parseNeko(InputSource input) throws Exception {
    DOMFragmentParser parser = new DOMFragmentParser();
    try {
        parser.setFeature("http://cyberneko.org/html/features/scanner/allow-selfclosing-iframe", true);
        parser.setFeature("http://cyberneko.org/html/features/augmentations", true);
        parser.setProperty("http://cyberneko.org/html/properties/default-encoding", defaultCharEncoding);
        parser.setFeature("http://cyberneko.org/html/features/scanner/ignore-specified-charset", true);
        parser.setFeature("http://cyberneko.org/html/features/balance-tags/ignore-outside-content", false);
        parser.setFeature("http://cyberneko.org/html/features/balance-tags/document-fragment", true);
        parser.setFeature("http://cyberneko.org/html/features/report-errors", LOG.isTraceEnabled());
    } catch (SAXException e) {
    }
    // convert Document to DocumentFragment
    HTMLDocumentImpl doc = new HTMLDocumentImpl();
    doc.setErrorChecking(false);
    DocumentFragment res = doc.createDocumentFragment();
    DocumentFragment frag = doc.createDocumentFragment();
    parser.parse(input, frag);
    res.appendChild(frag);
    try {
        while (true) {
            frag = doc.createDocumentFragment();
            parser.parse(input, frag);
            if (!frag.hasChildNodes())
                break;
            if (LOG.isInfoEnabled()) {
                LOG.info(" - new frag, " + frag.getChildNodes().getLength() + " nodes.");
            }
            res.appendChild(frag);
        }
    } catch (Exception e) {
        LOG.error("Error: ", e);
    }
    ;
    return res;
}
Also used : HTMLDocumentImpl(org.apache.html.dom.HTMLDocumentImpl) DOMFragmentParser(org.cyberneko.html.parsers.DOMFragmentParser) DocumentFragment(org.w3c.dom.DocumentFragment) DOMException(org.w3c.dom.DOMException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException) SAXException(org.xml.sax.SAXException)

Example 50 with DocumentFragment

use of org.w3c.dom.DocumentFragment in project nutch by apache.

the class HtmlParser method parseTagSoup.

private DocumentFragment parseTagSoup(InputSource input) throws Exception {
    HTMLDocumentImpl doc = new HTMLDocumentImpl();
    DocumentFragment frag = doc.createDocumentFragment();
    DOMBuilder builder = new DOMBuilder(doc, frag);
    org.ccil.cowan.tagsoup.Parser reader = new org.ccil.cowan.tagsoup.Parser();
    reader.setContentHandler(builder);
    reader.setFeature(org.ccil.cowan.tagsoup.Parser.ignoreBogonsFeature, true);
    reader.setFeature(org.ccil.cowan.tagsoup.Parser.bogonsEmptyFeature, false);
    reader.setProperty("http://xml.org/sax/properties/lexical-handler", builder);
    reader.parse(input);
    return frag;
}
Also used : HTMLDocumentImpl(org.apache.html.dom.HTMLDocumentImpl) DocumentFragment(org.w3c.dom.DocumentFragment) Parser(org.apache.nutch.parse.Parser) DOMFragmentParser(org.cyberneko.html.parsers.DOMFragmentParser)

Aggregations

DocumentFragment (org.w3c.dom.DocumentFragment)57 Document (org.w3c.dom.Document)27 Element (org.w3c.dom.Element)24 Node (org.w3c.dom.Node)20 NodeList (org.w3c.dom.NodeList)17 JAXBElement (javax.xml.bind.JAXBElement)8 Marshaller (javax.xml.bind.Marshaller)6 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 XMLStreamException (javax.xml.stream.XMLStreamException)5 DOMException (org.w3c.dom.DOMException)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 JAXBException (javax.xml.bind.JAXBException)4 DOMFragmentParser (org.cyberneko.html.parsers.DOMFragmentParser)4 Text (org.w3c.dom.Text)4 SAXException (org.xml.sax.SAXException)4 MalformedURLException (java.net.MalformedURLException)3 LinkedHashMap (java.util.LinkedHashMap)3 DocumentBuilder (javax.xml.parsers.DocumentBuilder)3 XMLStreamReader (javax.xml.stream.XMLStreamReader)3