Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > BSFException when using Javascript in XSL

Reply
Thread Tools

BSFException when using Javascript in XSL

 
 
Frank
Guest
Posts: n/a
 
      04-28-2004
Hey all,

I can't seem to get javascript running in my XSL document.

<?xml version="1.0"?>
<xsl:stylesheet xmlnssl="http://www.w3.org/1999/XSL/Transform"
version="1.0" xmlnsalan="http://xml.apache.org/xalan"
xmlns:my-ext="ext1" extension-element-prefixes="my-ext">
<!--The component and its script are in the xalan namespace and
define the
implementation of the extension.-->
<xalan:component prefix="my-ext" functions="hi">
<xalan:script lang="javascript">
function hi() {
return 5;
}
</xalan:script>
</xalan:component>
<xsl:template match="/deadline">
<xsl:value-of select="my-ext:hi()"/>
</xsl:template>
</xsl:stylesheet>

I get this huge stack trace:

java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.xalan.extensions.ExtensionHandlerGenera l.<init>(ExtensionHandlerGeneral.java:293)
at sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native
Method)
at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Construc tor.java:274)
at org.apache.xalan.extensions.ExtensionNamespaceSupp ort.launch(ExtensionNamespaceSupport.java:74)
at org.apache.xalan.extensions.ExtensionsTable.<init> (ExtensionsTable.java:11
at org.apache.xalan.transformer.TransformerImpl.setEx tensionsTable(TransformerImpl.java:437)
at org.apache.xalan.transformer.TransformerImpl.trans formNode(TransformerImpl.java:1169)
at org.apache.xalan.transformer.TransformerImpl.trans form(TransformerImpl.java:66
at org.apache.xalan.transformer.TransformerImpl.trans form(TransformerImpl.java:1129)
at org.apache.xalan.transformer.TransformerImpl.trans form(TransformerImpl.java:1107)
at org.apache.xalan.xslt.Process.main(Process.java:10 41)
Caused by: com.ibm.bsf.BSFException: JavaScript Error: Internal Error:
java.lang.IllegalArgumentException: Line number can not be negative:-1
at com.ibm.bsf.engines.javascript.JavaScriptEngine.ha ndleError(JavaScriptEngine.java:182)
at com.ibm.bsf.engines.javascript.JavaScriptEngine.ev al(JavaScriptEngine.java:87)
at com.ibm.bsf.util.BSFEngineImpl.exec(BSFEngineImpl. java:106)
... 17 more
javax.xml.transform.TransformerException:
java.lang.reflect.InvocationTargetException
at org.apache.xalan.extensions.ExtensionNamespaceSupp ort.launch(ExtensionNamespaceSupport.java:80)
at org.apache.xalan.extensions.ExtensionsTable.<init> (ExtensionsTable.java:11
at org.apache.xalan.transformer.TransformerImpl.setEx tensionsTable(TransformerImpl.java:437)
at org.apache.xalan.transformer.TransformerImpl.trans formNode(TransformerImpl.java:1169)
at org.apache.xalan.transformer.TransformerImpl.trans form(TransformerImpl.java:66
at org.apache.xalan.transformer.TransformerImpl.trans form(TransformerImpl.java:1129)
at org.apache.xalan.transformer.TransformerImpl.trans form(TransformerImpl.java:1107)
at org.apache.xalan.xslt.Process.main(Process.java:10 41)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInsta nce0(Native
Method)
at sun.reflect.NativeConstructorAccessorImpl.newInsta nce(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newI nstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Construc tor.java:274)
at org.apache.xalan.extensions.ExtensionNamespaceSupp ort.launch(ExtensionNamespaceSupport.java:74)
... 7 more
Caused by: javax.xml.transform.TransformerException: Could not compile
extension
at org.apache.xalan.extensions.ExtensionHandlerGenera l.<init>(ExtensionHandlerGeneral.java:300)
... 12 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.xalan.extensions.ExtensionHandlerGenera l.<init>(ExtensionHandlerGeneral.java:293)
... 12 more
Caused by: com.ibm.bsf.BSFException: JavaScript Error: Internal Error:
java.lang.IllegalArgumentException: Line number can not be negative:-1
at com.ibm.bsf.engines.javascript.JavaScriptEngine.ha ndleError(JavaScriptEngine.java:182)
at com.ibm.bsf.engines.javascript.JavaScriptEngine.ev al(JavaScriptEngine.java:87)
at com.ibm.bsf.util.BSFEngineImpl.exec(BSFEngineImpl. java:106)
... 17 more
---------

Any help greatly appreciated.

Thanks,
Frank
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: using css in html embedded in xml rendered using xsl with javascript (phew) confused XML 3 05-28-2007 11:55 AM
using css in html embedded in xml rendered using xsl with javascript (phew) confused XML 3 05-25-2007 11:06 PM
xsl:sort using an xsl:variable as the sort key jobooker@gmail.com XML 2 09-05-2006 03:51 PM
XSL Question tp xsl:for-each and xsl:variable schaf@2wire.ch XML 1 05-27-2005 09:25 PM
XSL-1000: (Fatal Error) Error while parsing XSL file (org.apache.xerces.parsers.AbstractSAXParser$AttributesProxy) Kevin Flood Java 0 09-08-2004 02:11 PM



Advertisments