Package org.dom4j.io

Examples of org.dom4j.io.HTMLWriter


                   
        OutputStream out = new FileOutputStream(name);
       
        boolean isHtml = outputMode != null && outputMode.equalsIgnoreCase( "html" );
        final XMLWriter xmlWriter = (isHtml)
            ? new HTMLWriter(out, format)
            : new XMLWriter(out, format);

        XMLOutput answer = new XMLOutput() {
            public void close() throws IOException {
                xmlWriter.close();
View Full Code Here


    }

    public void testDom4Xmlns() throws SAXException {
        StringWriter writer = new StringWriter();
        OutputFormat format = new OutputFormat();
        final XMLWriter xmlWriter = new HTMLWriter(writer, format);
        xmlWriter.setEscapeText(false);

        XMLOutput output = new XMLOutput(xmlWriter, xmlWriter);

        String golden = "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n";
        golden += "<html>";
View Full Code Here

            format.setSuppressDeclaration(true);
        }

        boolean isHtml = outputMode != null && outputMode.equalsIgnoreCase( "html" );
        final XMLWriter xmlWriter = (isHtml)
            ? new HTMLWriter(writer, format)
            : new XMLWriter(writer, format);

        xmlWriter.setEscapeText(isEscapeText());

        XMLOutput answer = new XMLOutput() {
View Full Code Here

    }

    public void testDom4Xmlns() throws SAXException {
        StringWriter writer = new StringWriter();
        OutputFormat format = new OutputFormat();
        final XMLWriter xmlWriter = new HTMLWriter(writer, format);
        xmlWriter.setEscapeText(false);

        XMLOutput output = new XMLOutput(xmlWriter, xmlWriter);

        String golden = "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n";
        golden += "<html>";
View Full Code Here

    OutputFormat format = OutputFormat.createPrettyPrint();
    format.setEncoding("utf-8");
    StringWriter writer = new StringWriter();

    HTMLWriter htmlWriter = new HTMLWriter(writer, format);

    htmlWriter.write(document);
    htmlWriter.close();
    return writer.toString();
  }
View Full Code Here

            format.setSuppressDeclaration(true);
        }

        boolean isHtml = outputMode != null && outputMode.equalsIgnoreCase( "html" );
        final XMLWriter xmlWriter = (isHtml)
            ? new HTMLWriter(writer, format)
            : new XMLWriter(writer, format);

        xmlWriter.setEscapeText(isEscapeText());

        XMLOutput answer = new XMLOutput() {
View Full Code Here

    }

    public void testDom4Xmlns() throws SAXException {
        StringWriter writer = new StringWriter();
        OutputFormat format = new OutputFormat();
        final XMLWriter xmlWriter = new HTMLWriter(writer, format);
        xmlWriter.setEscapeText(false);

        XMLOutput output = new XMLOutput(xmlWriter, xmlWriter);

        String golden = "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n";
        golden += "<html>";
View Full Code Here

    // -------------------------------------------------------------------------
    public void testWriter() throws Exception {
        String xml = "<html> <body><![CDATA[First&nbsp;test]]></body> </html>";
        Document document = DocumentHelper.parseText(xml);
        StringWriter buffer = new StringWriter();
        HTMLWriter writer = new HTMLWriter(buffer);
        writer.write(document);

        String output = buffer.toString();

        String expects = "\n<html>\n  <body>First&nbsp;test</body>\n</html>\n";
View Full Code Here

        format.setNewlines(true);
        format.setTrimText(true);
        format.setExpandEmptyElements(true);

        StringWriter buffer = new StringWriter();
        HTMLWriter writer = new HTMLWriter(buffer, format);
        writer.write(doc);

        String xml = buffer.toString();
        log(xml);

        int start = xml.indexOf("<root");
View Full Code Here

    public void testBug923882asWriter() throws Exception {
        // use an the HTMLWriter sax-methods.
        //
        StringWriter buffer = new StringWriter();
        HTMLWriter writer = new HTMLWriter(buffer, OutputFormat
                .createPrettyPrint());
        writer.characters("wor".toCharArray(), 0, 3);
        writer.characters("d-being-cut".toCharArray(), 0, 11);

        String expected = "word-being-cut";
        assertEquals(expected, buffer.toString());

        buffer = new StringWriter();
        writer = new HTMLWriter(buffer, OutputFormat.createPrettyPrint());
        writer.characters("    wor".toCharArray(), 0, 7);
        writer.characters("d being    ".toCharArray(), 0, 11);
        writer.characters("  cut".toCharArray(), 0, 5);

        expected = "word being cut";
        assertEquals(expected, buffer.toString());
    }
View Full Code Here

TOP

Related Classes of org.dom4j.io.HTMLWriter

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.