Examples of NekoHtmlSaxParser


Examples of org.apache.cocoon.components.NekoHtmlSaxParser

     * @param text the string to be tidied
     */
    private void normalize(String text) throws ProcessingException {
        Reader reader = new StringReader(text);
        try {
            NekoHtmlSaxParser parser = new NekoHtmlSaxParser(this.properties);

            DOMBuilder builder = new DOMBuilder();
            parser.setContentHandler(builder);
            parser.parse(new InputSource(reader));
            Document doc = builder.getDocument();

            IncludeXMLConsumer.includeNode(doc, this.contentHandler, this.lexicalHandler);
        } catch (Exception e) {
            throw new ProcessingException(
View Full Code Here

Examples of org.apache.cocoon.components.NekoHtmlSaxParser

     * Generate XML data.
     */
    public void generate()
    throws IOException, SAXException, ProcessingException {
        try {
            NekoHtmlSaxParser parser = new NekoHtmlSaxParser(this.properties);
           
            InputSource saxSource;
            if (this.requestParameterValue != null) {
                saxSource = new InputSource(new StringReader(this.requestParameterValue));
            }
            else {
                if (inputSource != null) {
                    requestStream = this.inputSource.getInputStream();
                }
                saxSource = new InputSource(requestStream);
            }
           
            if (xpath != null) {
                DOMBuilder builder = new DOMBuilder();
                parser.setContentHandler(builder);
                parser.parse(saxSource);
                Document doc = builder.getDocument();

                DOMStreamer domStreamer = new DOMStreamer(this.contentHandler,
                                                          this.lexicalHandler);
                this.contentHandler.startDocument();
                NodeList nl = processor.selectNodeList(doc, xpath);
                int length = nl.getLength();
                for(int i=0; i < length; i++) {
                    domStreamer.stream(nl.item(i));
                }
                this.contentHandler.endDocument();
            } else {
                parser.setContentHandler(this.contentHandler);
                parser.parse(saxSource);
            }
        } catch (IOException e){
            throw new ResourceNotFoundException("Could not get resource "
                + this.inputSource.getURI(), e);
        } catch (SAXException e){
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.