December 2002
Intermediate to advanced
672 pages
16h 53m
English
Scripted extensions are very similar to Java extensions, except the
extension is implemented inside of the
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 return value is placed into the result tree, but
you return null to disable this effect with
scripting languages. See Recipe 12.13 for an example.
Read now
Unlock full access