xml-xalan-j-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mk...@ca.ibm.com
Subject New extension stuff in Xalan
Date Thu, 10 Oct 2002 20:39:54 GMT
Hi,

There are a couple of changes in Xalan extensions after the 2.4.0 release.
These changes are targeted for the upcoming 2.5 release.

This document will give a brief summary of all the changes and new
features.

1. All extensions now use canonical namespace URIs starting with "
http://xml.apache.org/xalan". The following is a comparison table of the
old and new namespace URIs.

Extension             Old Namespace URI                 New Namespace URI
Java                  http://xml.apache.org/xslt/java
http://xml.apache.org/xalan/java
Redirect              None
http://xml.apache.org/xalan/redirect
PipeDocument          None
http://xml.apache.org/xalan/PipeDocument
SQL                   None
http://xml.apache.org/xalan/sql
component & script    http://xml.apache.org/xslt
http://xml.apache.org/xalan
Extension attrbitues  http://xml.apache.org/xslt
http://xml.apache.org/xalan
of xsl:output

The namespace URIs of the EXSLT extensions (math, sets, etc.) are still the
same (starting with "http://exslt.org/"). Backward compatibility is
maintained so that any stylesheet using the old namespace URIs will still
work.

Here is a stylesheet example that uses the old namespace URIs:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:lxslt="http://xml.apache.org/xslt"
    xmlns:redirect="org.apache.xalan.lib.Redirect"
    xmlns:java-ext="http://xml.apache.org/xslt/java"
    xmlns:my-ext="ext2" extension-element-prefixes="redirect">
  <xsl:output method="xml" indent="yes" lxslt:indent-amount="4"/>
  <lxslt:component prefix="my-ext" functions="getdate">
    <lxslt:script lang="javascript">
       function getdate(numdays) {}
    </lxslt:script>
  </lxslt:component>
  <xsl:template match="/">
    <redirect:write select="@file">
      <p><xsl:value-of select="my-ext:getdate(@attr)" /></p>
      <p><xsl:value-of select="java-ext:org.abc.test()" /></p>
    </redirect:write>
  </xsl:template>
</xsl:stylesheet>

Here is what the same stylesheet looks like when using the new namespace
URIs:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:xalan="http://xml.apache.org/xalan"
    xmlns:redirect="http://xml.apache.org/xalan/redirect"
    xmlns:java-ext="http://xml.apache.org/xalan/java"
    xmlns:my-ext="ext2" extension-element-prefixes="redirect">
  <xsl:output method="xml" indent="yes" xalan:indent-amount="4"/>
  <xalan:component prefix="my-ext" functions="getdate">
    <xalan:script lang="javascript">
       function getdate(numdays) {}
    </xalan:script>
  </xalan:component>
  <xsl:template match="/">
    <redirect:write select="@file">
      <p><xsl:value-of select="my-ext:getdate(@attr)" /></p>
      <p><xsl:value-of select="java-ext:org.abc.test()" /></p>
    </redirect:write>
  </xsl:template>
</xsl:stylesheet>

2. New EXSLT extension functions are added. You can now use functions in
the strings and dynamic modules. There are also more extension functions in
the math module.

3. Extension support in XSLTC was improved.
The Java extension support in XSLTC has been improved. You can now use all
three namespace formats (java, package and class) in XSLTC (see
http://xml.apache.org/xalan-j/extensions.html for details on namespace
formats). All usage syntax supported by Xalan can also be used with XSLTC.
There is only one exception: XSLTC does not support the notion of default
instance in class format namespace. You should always specify the instance
as the first parameter when using instance methods.

The following EXSLT extension modules are supported in XSLTC: common, math,
sets, dates-and-times and strings. The functions in the dynamic modules
(e.g. evaluate) are not supported because of a design limitation. To use
EXSLT extensions with XSLTC, you need to have xalan.jar on your CLASSPATH,
because XSLTC uses the same implementation classes in Xalan.

For XSLTC's own node-set and output extensions, you can still use them in
the old XSLTC native syntax. Now you can also use the Xalan syntax in
XSLTC. The output extension is aliased to redirect. So the following
stylesheet should work fine in XSLTC:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:exslt-common="http://exslt.org/common"
                xmlns:redirect="http://xml.apache.org/xalan/redirect"
                version="1.0">
  <xsl:variable name="abc"> ABC </xsl:variable>
  <xsl:template match="/">
    <redirect:write file="out.txt" append="yes">
      <xsl:value-of select="exslt-common:node-set($a)" />
    </redirect:write>
  </xsl:template>

Please feel free to give me any comments for future improvements.


Morris Kwan
XSLT Development
IBM Toronto Lab
Tel: (905)413-3729
Email: mkwan@ca.ibm.com


Mime
View raw message