Package org.apache.commons.jelly

Examples of org.apache.commons.jelly.XMLOutput


            value = reader.parse( url.toString() );
        }
        else {

            // invoke the body and pass that into the reader
            XMLOutput newOutput = new XMLOutput( reader );
           
            invokeBody(newOutput);
           
            value = reader.getRoot();
        }
View Full Code Here


            // now install the current output in the filter chain...
            // ####
           
            ContentHandler handler = filter.getContentHandler();
            handler.startDocument();
            invokeBody( new XMLOutput( handler ) );
            handler.endDocument();
            valid = filter.isValid();           
        }
        else {
          // outputting the errors to the current output
          verifier.setErrorHandler(
              new ErrorHandler() {
                  public void error(SAXParseException exception) throws SAXException {
                      outputException(output, "error", exception);
                  }
                 
                  public void fatalError(SAXParseException exception) throws SAXException {
                      outputException(output, "fatalError", exception);
                  }
                 
                  public void warning(SAXParseException exception) throws SAXException {
                      outputException(output, "warning", exception);
                  }
              }
          );
 
          VerifierHandler handler = verifier.getVerifierHandler();    
            handler.startDocument();
          invokeBody( new XMLOutput( handler ) );
            handler.endDocument();
            valid = handler.isValid();           
        }
        handleValid(valid);
    }
View Full Code Here

    /**
     * Parses the body of this tag and returns the parsed document
     */
    protected Document parseBody(XMLOutput output) throws Exception {
        SAXContentHandler handler = new SAXContentHandler();
        XMLOutput newOutput = new XMLOutput(handler);
        handler.startDocument();
        invokeBody( newOutput);
        handler.endDocument();
        return handler.getDocument();

View Full Code Here

    //-------------------------------------------------------------------------
    public void doTag(final XMLOutput output) throws Exception {
        if ( name == null ) {
            throw new MissingAttributeException( "name" );
        }
        XMLOutput newOutput = createXMLOutput();
        try {
            newOutput.startDocument();
            invokeBody(newOutput);
            newOutput.endDocument();
        }
        finally {
            newOutput.close();
        }
    }
View Full Code Here

        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();
            }
        };
        answer.setContentHandler(xmlWriter);
        answer.setLexicalHandler(xmlWriter);
        return answer;
    }
View Full Code Here

     * @param script is the URL to the script which should create a TestSuite
     * @return a newly created TestSuite
     */
    public static TestSuite createTestSuite(URL script) throws Exception {
        JellyContext context = new JellyContext(script);
        XMLOutput output = XMLOutput.createXMLOutput(System.out);
        context = context.runScript(script, output);
        TestSuite answer = (TestSuite) context.getVariable("org.apache.commons.jelly.junit.suite");
        if ( answer == null ) {
            log.warn( "Could not find a TestSuite created by Jelly for the script:" + script );
            // return an empty test suite
View Full Code Here

        JellyContext context = createContext();
        //context.registerTagLibrary("jelly:toxicity", mToxicityTagLibrary);
       
        try {
            ByteArrayOutputStream baos = new ByteArrayOutputStream();
            XMLOutput xmlOutput = XMLOutput.createXMLOutput(baos);
           
            InputSource is = XmlUtil.getInputSourceFromDom(pIn);
            // jelly will throw a malformed url exception if no system identifier is specified
            is.setSystemId("http://toxicity.sourceforge.net");
           
            context.runScript(is, xmlOutput);
            xmlOutput.flush();
           
            return XmlUtil.getDomFromInputStream(new ByteArrayInputStream(baos.toByteArray()));
           
        } catch (Exception e) {
            throw new ToxicityException(pIn, e);
View Full Code Here

        super.invokeBody(makeMuteOutput());
    }


    private XMLOutput makeMuteOutput() {
        return new XMLOutput(new DefaultHandler());
    }
View Full Code Here

        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>";

        output.startDocument();
        output.write(golden);
        output.endDocument();
        assertEquals("output should contain the namespaces", golden, writer.toString());
    }
View Full Code Here

             // supplied through the request object.
            this.updateContext();

            // Execute Jelly script
            StringWriter output = new StringWriter();
            XMLOutput xmlOutput = XMLOutput.createXMLOutput(output);
           
            scriptSource = this.resolver.resolveURI(this.source);
            this.jellyContext.runScript(scriptSource.getURI(), xmlOutput);
            xmlOutput.flush();
           
            InputSource inputSource = new InputSource(new StringReader(output.toString()));
            parser = (SAXParser) this.manager.lookup(SAXParser.ROLE);
            parser.parse(inputSource, super.xmlConsumer);
        } catch (IOException e) {
View Full Code Here

TOP

Related Classes of org.apache.commons.jelly.XMLOutput

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.