Wednesday, June 6, 2007

Apache Xalan from the Command Line

Check your Xalan environment:

C:\>java org.apache.xalan.xslt.EnvironmentCheck

Set your environment for the proper JARs (check the Apache site for updates):
C:\>set classpath=.;C:\jdk1.2.2\jre\lib\ext\xalan.jar;
C:\jdk1.2.2\jre\lib\ext\xercesImpl.jar;
C:\jdk1.2.2\jre\lib\ext\xml-apis.jar
Run a basic XSL transformation:

C:\>java org.apache.xalan.xslt.Process -IN c:\tmp\intput.xml -XSL c:\tmp\transform.xsl -OUT c:\tmp\output.xml

Additional command line options:

Common Options

-XSLTC (use XSLTC for transformation)
-IN inputXMLURL
-XSL XSLTransformationURL
-OUT outputFileName
-V (Version info)
-EDUMP [optional filename] (Do stackdump on error.)
-XML (Use XML formatter and add XML header.)
-TEXT (Use simple Text formatter.)
-HTML (Use HTML formatter.)
-PARAM name expression (Set a stylesheet parameter)
-MEDIA mediaType (use media attribute to find stylesheet associated with a document)
-FLAVOR flavorName (Explicitly use s2s=SAX or d2d=DOM to do transform)
-DIAG (Print overall milliseconds transform took)
-URIRESOLVER full class name (URIResolver to be used to resolve URIs)
-ENTITYRESOLVER full class name (EntityResolver to be used to resolve entities)
-CONTENTHANDLER full class name (ContentHandler to be used to serialize output)

Options for Xalan-Java Interpretive

-QC (Quiet Pattern Conflicts Warnings)
-TT (Trace the templates as they are being called)
-TG (Trace each generation event)
-TS (Trace each selection event)
-TTC (Trace the template children as they are being processed)
-TCLASS (TraceListener class for trace extensions)
-L (use line numbers for source document)
-INCREMENTAL (request incremental DTM construction by setting
http://xml.apache.org/xalan/features/incremental to true)
-NOOPTIMIMIZE (request no stylesheet optimization proccessing by setting
http://xml.apache.org/xalan/features/optimize to false)
-RL recursionlimit (assert numeric limit on stylesheet recursion depth)

For more information see http://xml.apache.org/xalan-j/commandline.html.

No comments: