Devsphere.com


com.devsphere.examples.xml.saxdomix
Class TransformerRunner

java.lang.Object
  |
  +--com.devsphere.examples.xml.saxdomix.TransformerRunner

public class TransformerRunner
extends java.lang.Object

This class is a generic launcher for Transformers.

The class that uses TransformerRunner must be a subclasses of Transformer, it must have a constructor that accepts only String parameters and it must call run() passing as parameters the full class name, the command line arguments and the names of the command line arguments that correspond to the constructor's parameters.

Usage Example:

    import com.devsphere.xml.saxdomix.SDXTransformer;

    import org.xml.sax.Attributes;
    import org.xml.sax.SAXException;

    import javax.xml.transform.TransformerException;
    import javax.xml.transform.stream.StreamSource;

    public class MyTransformer extends SDXTransformer {

        public MyTransformer(String xslSystemID)
                throws TransformerException {
            super(new StreamSource(xslSystemID));
        }

        public boolean wantDOM(String namespaceURI, String localName,
                String qualifiedName, Attributes attributes)
                throws SAXException {
            return ...
        }

        public static void main(String args[]) {
            TransformerRunner.run(MyTransformer.class.getName(),
                args, new String[] { "xsl" });
        }

    }

Command Line Syntax:

    java <className> -xsl <stylesheet> -in <input> [-out <output>]
    [-indent <amount>] [-method <method>] [-encoding <encoding>]
    [-omitdecl] [other application-specific parameters]

The run() method

See Also:
MixedTransformer, SmartTransformer, WrapperTransformer

Field Summary
static int DEFAULT_INDENT
          The default number of spaces for indenting
static java.lang.String XALAN_PREFFIX
          The prefix of the output properties that are Xalan specific
 
Constructor Summary
TransformerRunner()
           
 
Method Summary
static void run(java.lang.String className, java.lang.String[] args)
          Creates an instance of a Transformer subclass, configures it and calls its transform() method.
static void run(java.lang.String className, java.lang.String[] args, java.lang.String[] params)
          Creates an instance of a Transformer subclass, configures it and calls its transform() method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

XALAN_PREFFIX

public static final java.lang.String XALAN_PREFFIX
The prefix of the output properties that are Xalan specific

See Also:
Constant Field Values

DEFAULT_INDENT

public static final int DEFAULT_INDENT
The default number of spaces for indenting

See Also:
Constant Field Values
Constructor Detail

TransformerRunner

public TransformerRunner()
Method Detail

run

public static void run(java.lang.String className,
                       java.lang.String[] args)
Creates an instance of a Transformer subclass, configures it and calls its transform() method. It uses the constructor that takes the system ID of the XSLT stylesheet as parameter.


run

public static void run(java.lang.String className,
                       java.lang.String[] args,
                       java.lang.String[] params)
Creates an instance of a Transformer subclass, configures it and calls its transform() method. It uses the constructor with the given list of parameters.


 Devsphere.com