XML technologies / XSLT / XSLT Kochbuch / Extending and embedding XSLT / Script extension elements
(Excerpt from "XSLT Kochbuch" by Sal Mangano)
Script extensions are Java extensions, with the difference that these extensions are implemented within a xalan:script element:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xalan="http://xml.apache.org/xslt" xmlns:MyExt="xalan://com.AcmeX.MyExtensionElement" extension-element-prefixes="MyExt">
<xalan:component prefix="rep" elements="repeat">
<xalan:script lang="javascript">
function superExtension(ctx, elem)
{
/* ... */
return null ;
}
</xalan:script>
</xalan:component>
<xsl:template match="*">
<myExt:superExtension attr1="val1" attr2="val2">
<!-- ... -->
<myExt:superExtension>
</xsl:template>
</xsl:stylesheet>As with Java, the returned value is placed in the result tree, but here you return null to disable this effect for scripting languages. An example can be found in the recipe Extending XSLT with JavaScript.
XSLT 2.0
At present, I am not aware of any efforts to upgrade from Xalan to XSLT 2.0.
Copyright © 2006 O'Reilly Verlag GmbH & Co. KG
You may print the online version for your private use.
Otherwise, this chapter from "XSLT Kochbuch" is subject to the same terms as the printed edition: the work and all its parts are protected by copyright. All rights are reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
O'Reilly Verlag GmbH & Co. KG, Balthasarstraße 81, 50670 Köln, kommentar(at)oreilly.de