cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cocoon user <>
Subject Xalan Java Extensions and Cocoon
Date Fri, 28 Mar 2003 17:05:34 GMT

I am new to Cocoon and Xalan. I am trying to use the Xalan extensions so that I can write
Javascript programs within XSL and tranform them into html using Cocoon.

I am trying the example given in

This does not work with Cocoon. 

XML Source Document:

 <?xml version="1.0"?>
  <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"/>

XSL for transforming is:

<?xml version="1.0"?> 
<xsl:stylesheet xmlns:xsl=""

  <xalan:component prefix="counter"
                   elements="init incr" functions="read">
    <xalan: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");
        return null;

  <xsl:template match="/">
      <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"/>
        <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"/>
        <counter:incr name="index"/>

The Sitemap Configuration is:

      <map:match pattern="xalaneg.html">
        <map:generate type="file" src="content/xmlsrcdoc.xml" />
        <map:transform type="xslt" src="style/xalan.xsl" />                       
        <map:serialize type="html" />

I have bsf.jar, js.jar and jsstyle.jar in WEB-INF\lib of cocoon and also in the server classpath.


OS: Windows XP

App Server: Weblogic 7.0 (SP1)

JDK: JDK1.3.1

Cocoon version: Cocoon 2.0.4

The HTML output I get is:
Names in alphatebical order

What have I missed here?




Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
View raw message