Package org.dom4j.io

Examples of org.dom4j.io.SAXWriter


            }, saxFactory);
       
            ValidatorErrorHandler validatorErrorHandler = new ValidatorErrorHandler();
            Verifier verifier = new Verifier(docDeclaration, validatorErrorHandler);

            SAXWriter writer = new SAXWriter((ContentHandler) verifier);
            writer.setErrorHandler(validatorErrorHandler);

            writer.write(doc);
            if (verifier.isValid()) {
                return true;
            } else {
                Log.error(doc.getName() + " is invalid.");
                return false;
View Full Code Here


    @SuppressWarnings("rawtypes")
    @Override
    protected void process(ParsedDatum datum, Document doc, TupleEntryCollector collector,
                    FlowProcess process) throws Exception {
        SimpleBodyContentHandler bodyContentHandler = new SimpleBodyContentHandler();
        SAXWriter writer = new SAXWriter(bodyContentHandler);
        writer.write(doc);

        float pageScore = getScore(bodyContentHandler.toString());
       
        // Get the outlinks.
        Outlink[] outlinks = getOutlinks(doc);
View Full Code Here

            }, saxFactory);
       
            ValidatorErrorHandler validatorErrorHandler = new ValidatorErrorHandler();
            Verifier verifier = new Verifier(docDeclaration, validatorErrorHandler);

            SAXWriter writer = new SAXWriter((ContentHandler) verifier);
            writer.setErrorHandler(validatorErrorHandler);

            writer.write(doc);
            if (verifier.isValid()) {
                return true;
            } else {
                Log.error(doc.getName() + " is invalid.");
                return false;
View Full Code Here

    }

        if ( node instanceof Element ) {
            Element element = (Element) node;
           
            SAXWriter saxWriter = new SAXWriter(output, output);
           
            saxWriter.writeOpen(element);
            invokeBody(output);
            saxWriter.writeClose(element);
        }
        else {
            invokeBody(output);
        }
    }
View Full Code Here

       
        if (select == null) {
            throw new MissingAttributeException( "select" );
        }

        SAXWriter saxWriter = new SAXWriter(output, output);
        List nodes = select.selectNodes(xpathContext);
        for (Iterator iter = nodes.iterator(); iter.hasNext(); ) {
            Object object = iter.next();
            if ( object instanceof Node ) {
                saxWriter.write( (Node) object );
            }
            else if (object != null ) {
                output.write( object.toString() );
            }
        }
View Full Code Here

    protected Document roundTripSAX(Document document) throws Exception {
        // now lets write it back as SAX events to
        // a SAX ContentHandler which should build up a new document
        SAXContentHandler contentHandler = new SAXContentHandler();
        SAXWriter saxWriter = new SAXWriter(contentHandler, contentHandler,
                contentHandler);

        saxWriter.write(document);

        Document newDocument = contentHandler.getDocument();

        // lets ensure names are same
        newDocument.setName(document.getName());
View Full Code Here

        return dom4jDoc.getRootElement();
    }

    /** 将W3C element转换成SAX事件。 */
    public static void convertElement(Element element, ContentHandler contentHandler) throws SAXException {
        SAXWriter writer = new SAXWriter(contentHandler);

        if (contentHandler instanceof ErrorHandler) {
            writer.setErrorHandler((ErrorHandler) contentHandler);
        }

        if (contentHandler instanceof LexicalHandler) {
            writer.setLexicalHandler((LexicalHandler) contentHandler);
        }

        writer.write(convertElement(element));
    }
View Full Code Here

        return dom4jDoc.getRootElement();
    }

    /** 将W3C element转换成SAX事件。 */
    public static void convertElement(Element element, ContentHandler contentHandler) throws SAXException {
        SAXWriter writer = new SAXWriter(contentHandler);

        if (contentHandler instanceof ErrorHandler) {
            writer.setErrorHandler((ErrorHandler) contentHandler);
        }

        if (contentHandler instanceof LexicalHandler) {
            writer.setLexicalHandler((LexicalHandler) contentHandler);
        }

        writer.write(convertElement(element));
    }
View Full Code Here

    /**
     * ��W3C elementת����SAX�¼���
     */
    public static void convertElement(Element element, ContentHandler contentHandler) throws SAXException {
        SAXWriter writer = new SAXWriter(contentHandler);

        if (contentHandler instanceof ErrorHandler) {
            writer.setErrorHandler((ErrorHandler) contentHandler);
        }

        if (contentHandler instanceof LexicalHandler) {
            writer.setLexicalHandler((LexicalHandler) contentHandler);
        }

        writer.write(convertElement(element));
    }
View Full Code Here

        });

        System.out.println("Validating XML document");

        VerifierHandler handler = verifier.getVerifierHandler();
        SAXWriter writer = new SAXWriter(handler);
        writer.write(document);
    }
View Full Code Here

TOP

Related Classes of org.dom4j.io.SAXWriter

Copyright © 2018 www.massapicom. 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.