XML technologies / XSLT / XSLT Kochbuch / Extending and embedding XSLT / Java extension function with a namespace in class format

(Excerpt from "XSLT Kochbuch" by Sal Mangano)

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xalan="http://xml.apache.org/xslt" xmlns:Math="xalan://java.lang.Math">
  <xalan:component prefix="Math" functions="sin cos tan atan">
    <xalan:script lang="javaclass" src="xalan://java.lang.Math"/>
  </xalan:component>
  <xsl:variable name="pi" select="4.0 *"/>
  <!-- ... -->
</xsl:stylesheet>

If you use this form and omit the element xalan:component, your stylesheet works with both Saxon and Xalan.

  

 

 

 

back to top