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 http://xml.apache.org/xalan-j/extensions.html
This does not work with Cocoon.
XML Source Document:
<?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>
XSL for transforming is:
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xalan="http://xml.apache.org/xalan"
xmlns:counter="MyCounter"
extension-element-prefixes="counter"
version="1.0">
<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");
counters[name]++;
return null;
}
</xalan:script>
</xalan: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>
The Sitemap Configuration is:
<map:match pattern="xalaneg.html">
<map:generate type="file" src="" />
<map:transform type="xslt" src="" />
<map:serialize type="html" />
</map:match>
I have bsf.jar, js.jar and jsstyle.jar in WEB-INF\lib of cocoon and also in the server classpath.
Environment:
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?
Thanks.
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!