Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Embedding javascript code into the XSL

From: "J.Pietschmann" <j3322ptm@-------->
To:
Date: 5/1/2002 11:18:00 AM
David Carlisle wrote:



The normal extension language for the java XSLT engines is java rather
than javascript (but you need to check the docs for each processor)

Xalan can be extended using JavaScript. It does so, of
course, in a slightly different way that MSXML. You'll
need bsf.jar (the Bean Scripting Framework) an a JavaScript
implementation (i used rhino http://www.mozilla.org/rhino/)
I think bsf.jar is already distributed with Xalan.

Here is an example on how to define and use JavaScript
functios in Xalan:

<?xml version='1.0' encoding='ISO-8859-1' ?>
<xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:lxslt="http://xml.apache.org/xslt"
  xmlns:counter="ext1"
  extension-element-prefixes="counter">
  <lxslt:component prefix="counter" functions="count">
    <lxslt:script lang="javascript">
   var i = 1;
   function count() {
      i++;
      return i;
   }
    </lxslt:script>
  </lxslt:component>

  <xsl:template match="/">
    <xsl:value-of select="counter:count()" />
    <xsl:text>&#x0A;</xsl:text>
    <xsl:value-of select="counter:count()" />
  </xsl:template>
</xsl:stylesheet>

Note that you should really know what you are doing,
your stylesheets will be non-protable and have a good
chance to grow into a maintenance nightmare.

J.Pietschmann







XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


transparent
Print
Mail
Digg
delicious
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent