Engine_XalanJ

Version 25.1 by Nicolas Gregoire on 2012/01/11 22:27

Xalan-J is a Java based XSLT engine by the Apache Project.

Supported version

1.0

Command line

$> java org.apache.xalan.xslt.Process -in foo.xml -xsl foo.xsl

Note : xml-apis.jar, xercesImpl.jar and xalan*.jar must be in the $CLASSPATH

Identification strings

xsl:vendor-urlhttp://xml.apache.org/xalan-j
xsl:vendorApache Software Foundation
xsl:version1.0

Special features

  • File creation
  • Code execution
  • JDBC connectivity
  • Java properties
  • CheckEnv()

CheckEnv()

The checkEnvironment() extension function (documented here), associated to the Xalan namespace, will display some information about the execution context.

Output

<?xml version="1.0" encoding="UTF-8"?>

<checkEnvironmentExtension>
      <EnvironmentCheck version="$Revision$">
      <environment>
 <item key="version.DOM.draftlevel">2.0fd</item>
 <item key="java.class.path">/usr/share/java/xalan2.jar:/usr/share/java/xml-apis.jar:/usr/share/java/xercesImpl.jar:/usr/share/java/serializer.jar:/usr/share/java/xsltc.jar</item>
 <item key="version.JAXP">1.1 or higher</item>
 <item key="java.ext.dirs">/usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/ext:/usr/java/packages/lib/ext</item>
 <item key="version.xerces2">Xerces-J 2.9.1</item>
 <item key="version.xerces1">not-present</item>
 <item key="version.xalan2_2">Xalan Java 2.7.1</item>
 <item key="version.xalan1">not-present</item>
 <item key="version.ant">not-present</item>
 <item key="java.version">1.6.0_26</item>
 <item key="version.DOM">2.0</item>
 <item key="version.crimson">not-present</item>
 <item key="sun.boot.class.path">/usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/resources.jar:/usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/rt.jar:/usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/jsse.jar:/usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/jce.jar:/usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/charsets.jar:/usr/lib/jvm/java-6-sun-1.6.0.26/jre/lib/modules/jdk.boot.jar:/usr/lib/jvm/java-6-sun-1.6.0.26/jre/classes</item>
 <foundJar desc="apis.jar-apparent.version" name="xml">xml-apis.jar present-unknown-version</foundJar>
 <foundJar desc="apis.jar-path" name="xml">/usr/share/java/xml-apis.jar</foundJar>
 <foundJar desc="apparent.version" name="xercesImpl.jar">xercesImpl.jar WARNING.present-unknown-version</foundJar>
 <foundJar desc="path" name="xercesImpl.jar">/usr/share/java/xercesImpl.jar</foundJar>
 <foundJar desc="apparent.version" name="serializer.jar">serializer.jar present-unknown-version</foundJar>
 <foundJar desc="path" name="serializer.jar">/usr/share/java/serializer.jar</foundJar>
 <foundJar desc="apparent.version" name="xsltc.jar">xsltc.jar present-unknown-version</foundJar>
 <foundJar desc="path" name="xsltc.jar">/usr/share/java/xsltc.jar</foundJar>
 <item key="version.SAX">2.0</item>
 <item key="version.xalan2x">Xalan Java 2.7.1</item>
 </environment>
 <status result="OK"/>
 </EnvironmentCheck>
</checkEnvironmentExtension>

Java code execution

The following code will display the current date :

TODO

Execution of external commands

The following code will execute the command "touch /tmp/hello" :

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:j="http://xml.apache.org/xalan/java"
                exclude-result-prefixes="j"
                version="1.0">
    <xsl:template match="/">
        <xsl:variable name="c"><![CDATA[touch = /tmp/hello]]></xsl:variable>
        <xsl:variable name="a" select="j:split($c, ' = ')"/>
        <xsl:variable name="r" select="j:java.lang.Runtime.getRuntime()"/>
        <xsl:variable name="p" select="j:exec($r, $a )"/>
        No content at the moment ...
    </xsl:template>
</xsl:stylesheet>