BSFException when using Javascript in XSL

Discussion in 'XML' started by Frank, Apr 28, 2004.

  1. Frank

    Frank Guest

    Hey all,

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

    <?xml version="1.0"?>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0" xmlns:xalan="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(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at org.apache.xalan.extensions.ExtensionHandlerGeneral.<init>(ExtensionHandlerGeneral.java:293)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
    Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
    at org.apache.xalan.extensions.ExtensionNamespaceSupport.launch(ExtensionNamespaceSupport.java:74)
    at org.apache.xalan.extensions.ExtensionsTable.<init>(ExtensionsTable.java:118)
    at org.apache.xalan.transformer.TransformerImpl.setExtensionsTable(TransformerImpl.java:437)
    at org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1169)
    at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:668)
    at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1129)
    at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1107)
    at org.apache.xalan.xslt.Process.main(Process.java:1041)
    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.handleError(JavaScriptEngine.java:182)
    at com.ibm.bsf.engines.javascript.JavaScriptEngine.eval(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.ExtensionNamespaceSupport.launch(ExtensionNamespaceSupport.java:80)
    at org.apache.xalan.extensions.ExtensionsTable.<init>(ExtensionsTable.java:118)
    at org.apache.xalan.transformer.TransformerImpl.setExtensionsTable(TransformerImpl.java:437)
    at org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1169)
    at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:668)
    at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1129)
    at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1107)
    at org.apache.xalan.xslt.Process.main(Process.java:1041)
    Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
    Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
    at org.apache.xalan.extensions.ExtensionNamespaceSupport.launch(ExtensionNamespaceSupport.java:74)
    ... 7 more
    Caused by: javax.xml.transform.TransformerException: Could not compile
    extension
    at org.apache.xalan.extensions.ExtensionHandlerGeneral.<init>(ExtensionHandlerGeneral.java:300)
    ... 12 more
    Caused by: java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:324)
    at org.apache.xalan.extensions.ExtensionHandlerGeneral.<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.handleError(JavaScriptEngine.java:182)
    at com.ibm.bsf.engines.javascript.JavaScriptEngine.eval(JavaScriptEngine.java:87)
    at com.ibm.bsf.util.BSFEngineImpl.exec(BSFEngineImpl.java:106)
    ... 17 more
    ---------

    Any help greatly appreciated.

    Thanks,
    Frank
     
    Frank, Apr 28, 2004
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kevin Flood
    Replies:
    0
    Views:
    1,033
    Kevin Flood
    Sep 8, 2004
  2. Replies:
    1
    Views:
    3,637
    A. Bolmarcich
    May 27, 2005
  3. Replies:
    2
    Views:
    9,307
    Martin Honnen
    Sep 5, 2006
  4. confused
    Replies:
    3
    Views:
    405
    David Carlisle
    May 26, 2007
  5. confused
    Replies:
    3
    Views:
    447
    Pavel Lepin
    May 28, 2007
Loading...

Share This Page