Package com.volantis.xml.pipeline.sax.drivers.web.conditioners

Examples of com.volantis.xml.pipeline.sax.drivers.web.conditioners.HTMLResponseConditioner



        // create the actual parser
        XMLReader parser = XMLReaderFactory.createXMLReader(false);
        XMLFilterImpl xmlFilter = new XMLFilterImpl(parser);
        HTMLResponseConditioner conditioner = new HTMLResponseConditioner(xmlFilter);


        XMLProcessImpl xmlProcess = new XMLProcessImpl() {
            public void setDocumentLocator(Locator locator) {
                XMLProcess consumer = getConsumerProcess();
                if (null != consumer) {
                    consumer.setDocumentLocator(locator);
                }
            }

            public void startDocument() throws SAXException {
                XMLProcess consumer = getConsumerProcess();
                if (null != consumer) {
                    consumer.startDocument();
                }
            }

            public void endDocument() throws SAXException {
                XMLProcess consumer = getConsumerProcess();
                if (null != consumer) {
                    consumer.endDocument();
                }
            }

            // Javadoc inherited
            public void startPrefixMapping(String prefix, String uri)
                    throws SAXException {
                XMLProcess consumer = getConsumerProcess();
                if (null != consumer) {
                    consumer.startPrefixMapping(prefix, uri);
                }
            }

            // Javadoc inherited
            public void endPrefixMapping(String prefix) throws SAXException {
                XMLProcess consumer = getConsumerProcess();
                if (null != consumer) {
                    consumer.endPrefixMapping(prefix);
                }
            }
        };
        xmlProcess.setNextProcess(adapter);

        ByteArrayOutputStream out = new ByteArrayOutputStream();
        byte[] buffer = new byte[2048];
        int readBytes = input.read(buffer);
        while (readBytes != -1) {
            out.write(buffer, 0, readBytes);
            readBytes = input.read(buffer);
        }

        InputSource inputSource = new InputSource(
                new ByteArrayInputStream(out.toByteArray()));
        conditioner.condition(inputSource, xmlProcess);

        outputWriter.flush();
        char[] outputCharacters = outputWriter.toCharArray();
        String charsetName = "ISO-8859-1";
        XMLAssert.assertXMLEqual(new InputStreamReader(expected, charsetName),
View Full Code Here


     */
    public static ContentConditioner
            createContentTypeConditioner(String contentType, XMLFilter filter) {
        ContentConditioner conditioner;
        if (contentType.startsWith("text/html")) {
            conditioner = new HTMLResponseConditioner(filter);
        } else {
            conditioner = new XMLResponseConditioner(filter);
        }
        return conditioner;
    }   
View Full Code Here

TOP

Related Classes of com.volantis.xml.pipeline.sax.drivers.web.conditioners.HTMLResponseConditioner

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.