You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by david sempr <se...@hotmail.com> on 2001/01/04 17:29:52 UTC

help example

hi,
I have more problem using and working with
example that I have copied from the web,In particular I want use the
extension element to include javascript code inside my xsl.

The problem is that the follow example and other don't work in my server,
I have checked the classpath in file
jserv.properties it is:

wrapper.classpath=/eidos/home/muvi002/httpd/cocoon-1.8/bin/cocoon.jar
wrapper.classpath=/eidos/home/muvi002/httpd/cocoon-1.8/lib/ant_1_1.jar
wrapper.classpath=/eidos/home/muvi002/httpd/cocoon-1.8/lib/turbine-pool.jar
wrapper.classpath=/eidos/home/muvi002/httpd/cocoon-1.8/lib/xerces_1_2.jar
wrapper.classpath=/eidos/home/muvi002/httpd/cocoon-1.8/lib/fop_0_13_0.jar
wrapper.classpath=/eidos/home/muvi002/httpd/cocoon-1.8/lib/xalan_1_2_D02.jar
wrapper.classpath=/eidos/home/muvi002/httpd/cocoon-1.8/lib/bsf.jar
wrapper.classpath=/eidos/home/muvi002/httpd/cocoon-1.8/lib/stylebook-1.0-b2.jar
wrapper.classpath=/eidos/home/muvi002/httpd/cocoon-1.8/lib/bsfengines.jar

I have included all that xalang extension need!!!
how is the problem????

this is the code of my example:

file prova.xml ________________________________________

<?xml version="1.0"?>
<?cocoon-process type="xslt"?>
<?xml-stylesheet href="prova.xsl" type="text/xsl"?>
<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>

file prova.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="javascript1.1">
     var counters = new Array();

     function init (xslprocContext, 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 (xslprocContext, elem)
     {
alert("ciao");
       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>

and what appear in my i.e browser :


Names in alphatebical order
[]. Bertoni, David

[]. Boag, Scott

[]. Curcuru, Shane

[]. Dick, Paul

[]. Donohue, Jack

[]. Farmer, Emily

[]. Leslie, Donald

[]. Marston, David

[]. Midy, Myriam

[]. Weir, Robert



the element function don't work!!!


tanks a lot!!

semprini davide