You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by "Karavettil, Suren" <sk...@zooba.com> on 2000/12/01 15:02:42 UTC

call to extension element failed:

This the issue when i try to transform the XML shown below using the XSL
shown below. The error message that i get is here. Actually i'm trying to
use JavaScript functions in the XSL. I've also included bsf.jar; js.jar;
bsfengines.jar in the classpath.
This is the sample given at the Apache.org site. I would appreciate if
somebody gives me some assistance.

Error Message
===================

>e:\phaseiii\test > java ZoobaEmailDom 
>e:\phaseiii\test > Call to extension element failed:  File
"file:E:/PHASEIII/test/MyCounter" not found.

Sample XML
==============
<?xml version="1.0"?>
<doc>
  <name first="David" last="Marston"/>
  <name first="David" last="Bertoni"/>
  <name first="Donald" last="Leslie"/>
  <name first="Emily" last="Farmer"/>
  <name first="Jack" last="Donohue"/>
  <name first="Myriam" last="Midy"/>
  <name first="Paul" last="Dick"/>
  <name first="Robert" last="Weir"/>
  <name first="Scott" last="Boag"/>
  <name first="Shane" last="Curcuru"/>
</doc>

sample XSL
=============
<?xml version="1.0"?> 
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:lxslt="http://xml.apache.org.xslt"
                xmlns:counter="MyCounter"
                extension-element-prefixes="counter"
                version="1.0">

  <lxslt:component prefix="counter"
                   elements="init incr" functions="read">
    <lxslt:script lang="javascript">
      var counters = new Array();

      function init (xslproc, elem) {
        name = elem.getAttribute ("name");
        value = parseInt(elem.getAttribute ("value"));
        counters[name] = value;
        return null;
      }

      function read (name) {
        // Return a string.
        return "" + (counters[name]);
      }

      function incr (xslproc, elem)
      {
        name = elem.getAttribute ("name");
        counters[name]++;
        return null;
      }
    </lxslt:script>
  </lxslt:component>

  <xsl:template match="/">
    <HTML>
      <H1>Names in alphatebical order</H1>
      <counter:init name="index" value="1"/>
      <xsl:for-each select="doc/name">
        <xsl:sort select="@last"/>
        <xsl:sort select="@first"/>
        <p>
        <xsl:text>[</xsl:text>
        <xsl:value-of select="counter:read('index')"/>
        <xsl:text>]. </xsl:text>
        <xsl:value-of select="@last"/>
        <xsl:text>, </xsl:text>
        <xsl:value-of select="@first"/>
        </p>
        <counter:incr name="index"/>
      </xsl:for-each>
    </HTML>
  </xsl:template>
 
</xsl:stylesheet>


>e:\phaseiii\test > java ZoobaEmailDom 
>e:\phaseiii\test > Call to extension element failed:  File
"file:E:/PHASEIII/test/MyCounter" not found.

Thanks
Suren.


Re: call to extension element failed:

Posted by Gary L Peskin <ga...@firstech.com>.
> "Karavettil, Suren" wrote:
> ...
> This is the sample given at the Apache.org site.

Well, almost.

> ...
>                 xmlns:lxslt="http://xml.apache.org.xslt"

The correct namespace is

  xmlns:lxslt="http://xml.apache.org/xslt

Gary