Package org.apache.commons.jelly

Examples of org.apache.commons.jelly.XMLOutput


     *             on error creating XML output and handling System.err and out
     */
    protected void initializeRootContext() throws IOException
    {
        this.writer = new OutputStreamWriter( System.out );
        XMLOutput output = XMLOutput.createXMLOutput( writer, false );

        if ( getCli().hasOption( OPT_WORKING_DIR ) )
        {
            String workingDir = getCli().getOptionValue( OPT_WORKING_DIR );
            File dir = new File( workingDir );
View Full Code Here


             // (from sitemap parameters) will be overriden, if same variables are
             // supplied through the request object.
            this.updateContext();

            // Execute Jelly script
            XMLOutput xmlOutput = new XMLOutput(this.contentHandler, this.lexicalHandler);
           
            // TODO - Compile the script and cache the compiled version
           
            scriptSource = this.resolver.resolveURI(this.source);
           
            Script script = this.jellyParser.parse(SourceUtil.getInputSource(scriptSource));
            script = script.compile();
           
            // the script does not output startDocument/endDocument events
            this.contentHandler.startDocument();
            script.run(this.jellyContext, xmlOutput);
            xmlOutput.flush();
            this.contentHandler.endDocument();
           
        } catch (IOException e) {
            getLogger().error("JellyGenerator.generate()", e);
            throw new ResourceNotFoundException("JellyGenerator could not find resource", e);
View Full Code Here

            "<?xml version=\"1.0\"?>"
                + " <j:jelly xmlns:j=\"jelly:core\">"
                + "jelly-test-case"
                + " </j:jelly>";
       ByteArrayOutputStream output = new ByteArrayOutputStream();
       XMLOutput xmlOutput = XMLOutput.createXMLOutput(output);
       InputSource script = new InputSource( new StringReader(message.toString()) );
       JellyContext context = new JellyContext();
       context.runScript( script, xmlOutput);
       output.close();
       //check that the output confirms the expected
View Full Code Here

            throws IOException, SAXException, JellyException {
        Runtime rt = Runtime.getRuntime();
        JellyContext jc = new JellyContext();
        jc.setClassLoader(getClass().getClassLoader());

        XMLOutput output = XMLOutput.createDummyXMLOutput();
       
        URL url = this.getClass().getResource(scriptName);

        String exturl = url.toExternalForm();
        int lastSlash = exturl.lastIndexOf("/");
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

    /**
     * Writes the body fo this tag to the given Writer
     */
    protected void writeBody(Writer writer) throws SAXException, JellyTagException {

        XMLOutput newOutput = createXMLOutput(writer);
        try {
            // we need to avoid multiple start/end document events
            newOutput.setContentHandler(
                new SafeContentHandler(newOutput.getContentHandler())
            );
            newOutput.startDocument();
            invokeBody(newOutput);
            newOutput.endDocument();
        }
        finally {
            try { newOutput.close(); } catch (IOException e) {}
        }
    }
View Full Code Here

            ? new HTMLWriter(writer, format)
            : new XMLWriter(writer, format);

        xmlWriter.setEscapeText(isEscapeText());

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

        HttpServletRequest req,
        HttpServletResponse res)
        throws IOException, UnsupportedEncodingException, JellyException {

        ServletOutputStream output = res.getOutputStream();
        XMLOutput xmlOutput = XMLOutput.createXMLOutput(output);
        context.runScript(script, xmlOutput);
        xmlOutput.flush();
        xmlOutput.close();
        output.flush();
    }
View Full Code Here

    /**
     * Parses the body of this tag and returns the parsed document
     */
    protected void parseBody(XMLOutput output) throws JellyTagException {
        ContentHandler handler = getJellyParser();
        XMLOutput newOutput = new XMLOutput(handler);

        try {
            handler.startDocument();
            invokeBody(newOutput);
            handler.endDocument();
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

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.