Package org.apache.commons.jelly

Examples of org.apache.commons.jelly.XMLOutput


            throw new JellyException("Script file " + scriptFile + " not found");
        }

        try {
            // extract the -o option for the output file to use
            final XMLOutput output = cmdLine.hasOption("o") ?
                    XMLOutput.createXMLOutput(new FileWriter(cmdLine.getOptionValue("o"))) :
                    XMLOutput.createXMLOutput(System.out);

            Jelly jelly = new Jelly();
            jelly.setScript(scriptFile);

            final Script script = jelly.compileScript();

            // add the system properties and the command line arguments
            final JellyContext context = jelly.getJellyContext();
            context.setVariable("args", args);
            context.setVariable("commandLine", cmdLine);
            if (runInSwingThread) {
                javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() {
                    try {
                        script.run(context, output);
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
            } } ); } else {
                script.run(context, output);
            }

            // now lets wait for all threads to close
            Runtime.getRuntime().addShutdownHook(new Thread() {
                    public void run() {
                        try {
                            output.close();
                        }
                        catch (Exception e) {
                            // ignore errors
                        }
                    }
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

        jellyContext.setVariable( "context",
                                   context );

        try
        {
            XMLOutput output = XMLOutput.createXMLOutput( System.err,
                                                          false );

            getScript().run( jellyContext,
                             output );
        }
View Full Code Here

        jellyContext.setVariable( "blissed_context",
                                  context );

        try
        {
            XMLOutput output = XMLOutput.createXMLOutput( System.err,
                                                          false );

            getScript().run( jellyContext,
                             output );
        }
View Full Code Here

  }

  private String compileJelly(JellyContext context, String template) {
    StringWriter writer = new StringWriter();
    try {
      XMLOutput xmlOutput = XMLOutput.createXMLOutput(writer);
      String url = this.getClass()
          .getResource("MasterMailer.class").toString();
      url = url.substring(0, url.lastIndexOf(".class"));
      context.runScript(url + "/" + template, xmlOutput);
      xmlOutput.flush();
    } catch (Exception e) {
      e.printStackTrace(new PrintWriter(writer));
    }

    return 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

    //-------------------------------------------------------------------------
    public void doTag(final XMLOutput output) throws Exception {
        if ( name == null ) {
            throw new MissingAttributeException( "name" );
        }
        XMLOutput newOutput = XMLOutput.createXMLOutput(new FileOutputStream(name));
        try {
            newOutput.startDocument();
            invokeBody(newOutput);
            newOutput.endDocument();
        }
        finally {
            newOutput.close();
        }
    }
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();           
        }
        if (var != null ) {
            Boolean value = (valid) ? Boolean.TRUE : Boolean.FALSE;
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.