Package org.apache.commons.jelly

Examples of org.apache.commons.jelly.Script


            XMLOutput newOutput = new XMLOutput(handler);
            handler.startDocument();
            invokeBody(newOutput);
            handler.endDocument();
            // Run script to generate output
            Script script = getJellyParser().getScript();
            script.run(context, output);
        } catch (JellyTagException e) {
            if (e.getCause() instanceof SAXException) {
                throw (SAXException)e.getCause();
            } else {
                throw e;
View Full Code Here


  ExtXMLParser jellyParser = new ExtXMLParser ();
  jellyParser.setContext(context);
  jellyParser.configure ();
  reader.setContentHandler(new NamespaceAttributesFilter(jellyParser));
  reader.parse (inSrc);
  Script script = jellyParser.getScript ();
  script.compile ();
  script.run (context, XMLOutput.createXMLOutput(System.out));
    }
View Full Code Here

      JellyContext context = new JellyContext (jellyContext ());
      ExtXMLParser jellyParser = new ExtXMLParser ();
      jellyParser.setContext(context);
      jellyParser.configure ();
      seb.emit (new NamespaceAttributesFilter(jellyParser));
      Script script = jellyParser.getScript ();
      script.compile ();
      SAXEventBufferImpl jres = new SAXEventBufferImpl ();
      jres.startDocument ();
      script.run (context, new XMLOutput(jres));
      jres.endDocument ();
      jres.pack ();
      return jres;
  } catch (JellyException e) {
      throw (IllegalArgumentException)(new IllegalArgumentException
View Full Code Here

           
            // 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);
View Full Code Here

           
            // 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);
View Full Code Here

   
       
    protected Document runScript(String fileName) throws Exception {
        InputStream in = new FileInputStream(fileName);
        XMLParser parser = new XMLParser();
        Script script = parser.parse(in);
        script = script.compile();
        JellyContext context = parser.getContext();
       
        SAXContentHandler contentHandler = new SAXContentHandler();
        XMLOutput output = new XMLOutput( contentHandler );
       
        contentHandler.startDocument();
        script.run(context, output);
        contentHandler.endDocument();
       
        return contentHandler.getDocument();
    }
View Full Code Here

     * Tests that parsing an example script correctly creates the parent relationships
     */
    public void testParser() throws Exception {
        InputStream in = new FileInputStream("src/test/org/apache/commons/jelly/sql/example2.jelly");
        XMLParser parser = new XMLParser();
        Script script = parser.parse(in);
        script = script.compile();
       
        log.debug("Found: " + script);
       
        assertTagsHaveParent( script, null );
    }
View Full Code Here

    }
   
    public void testParse() throws Exception {
        InputStream in = new FileInputStream("src/test/org/apache/commons/jelly/xml/example.jelly");
        XMLParser parser = new XMLParser();
        Script script = parser.parse(in);
        script = script.compile();
        log.debug("Found: " + script);
        assertTrue("Parsed a Script", script instanceof Script);
        StringWriter buffer = new StringWriter();
        script.run(parser.getContext(), XMLOutput.createXMLOutput(buffer));
        String text = buffer.toString().trim();
        if (log.isDebugEnabled()) {
            log.debug("Evaluated script as...");
            log.debug(text);
        }
View Full Code Here

   
    public Document parseUnitTest(String name) throws Exception {
        // parse script
        InputStream in = new FileInputStream(name);
        XMLParser parser = new XMLParser();
        Script script = parser.parse(in);
        script = script.compile();
        assertTrue("Parsed a Script", script instanceof Script);
        StringWriter buffer = new StringWriter();
        script.run(parser.getContext(), XMLOutput.createXMLOutput(buffer));

        String text = buffer.toString().trim();
        if (log.isDebugEnabled()) {
            log.debug("Evaluated script as...");
            log.debug(text);
View Full Code Here

    }

    public void testArgs() throws Exception {
        InputStream in = new FileInputStream("src/test/org/apache/commons/jelly/test_args.jelly");
        XMLParser parser = new XMLParser();
        Script script = parser.parse(in);
        script = script.compile();
        log.debug("Found: " + script);
        assertTrue("Parsed a Script", script instanceof Script);
        String[] args = { "one", "two", "three" };
        JellyContext context = new JellyContext();
        context.setVariable("args", args);
        StringWriter buffer = new StringWriter();
        script.run(context, XMLOutput.createXMLOutput(buffer));
        String text = buffer.toString().trim();
        if (log.isDebugEnabled()) {
            log.debug("Evaluated script as...");
            log.debug(text);
        }
View Full Code Here

TOP

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

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.