Subject:xalan:component Author:Maggie Khoo Date:21 Feb 2007 07:18 PM
I am using the example provided in xalan.apache.org website but I am getting an error.
java.lang.NullPointerException
I added bsf.jar, bsfengines.jar and js.jar into my classpath. Is there any conflict between the versions?
Any suggestions?
<?xml version="1.0"?>
<!--Namespaces are global if you set them in the stylesheet element-->
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:lxslt="http://xml.apache.org/xslt"
xmlns:my-ext="ext1"
extension-element-prefixes="my-ext">
<!--The component and its script are in the lxslt namespace and define the
implementation of the extension.-->
<lxslt:component prefix="my-ext" elements="timelapse" functions="getdate">
<lxslt:script lang="javascript">
var multiplier=1;
// The methods or functions that implement extension elements always take 2
// arguments. The first argument is the XSL Processor context; the second
// argument is the element node.
function timelapse(xslProcessorContext, elem)
{
multiplier=parseInt(elem.getAttribute("multiplier"));
// The element return value is placed in the result tree.
// If you do not want a return value, return null.
return null;
}
function getdate(numdays)
{
var d = new Date();
var totalDays = parseInt(numdays) * multiplier;
d.setDate(d.getDate() + totalDays);
return d.toLocaleString();
}
</lxslt:script>
</lxslt:component>
<xsl:template match="/">
<p><my-ext:timelapse multiplier="2"/>We have logged your enquiry and will
respond by <xsl:value-of select="my-ext:getdate(string(@numdays))"/>.</p>
</xsl:template>
Subject:xalan:component Author:(Deleted User) Date:26 Feb 2007 08:25 AM
Hi Maggie,
are you trying to execute this stylesheet from within Stylus, or from the Xalan command line? If the answer is 'from Stylus', which version are you running?