Engine_XalanJ

Version 15.1 by Nicolas Gregoire on 2012/01/08 19:45

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

Supported XSLT version : 1.0

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 following code will display some information about the execution context :

checkenv.xsl

TODO

Code

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                             xmlns:xalan="http://xml.apache.org/xalan"
                              exclude-result-prefixes="xalan"
                              version="1.0">

     <xsl:output indent="yes"/>
      <xsl:template match="/">
          <xsl:copy-of select="xalan:checkEnvironment()"/>

       </xsl:template>

</xsl:stylesheet>

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/xalan25.jar:/usr/share/java/bsf-2.4.0.jar</item>
<item key="version.JAXP">1.1 or higher</item>
<item key="java.ext.dirs">/usr/lib/jvm/java-6-openjdk/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_20</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-openjdk/jre/lib/resources.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/rt.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/sunrsasign.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/jsse.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/jce.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/charsets.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/netx.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/plugin.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/rhino.jar:/usr/lib/jvm/java-6-openjdk/jre/lib/modules/jdk.boot.jar:/usr/lib/jvm/java-6-openjdk/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>
<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>