Is it possible to call Java functions from XSLT, using standard Java 6?

I have seen examples, but the examples are always the most simple case, which even I can already get working. The case where no arguments are passed to the java function.
As soon as I try to pass an argument to the java function, i get a stupid unhelpful error message (as always error messages are unhelpful).
Or am I wasting my time using the standard provided java parser, and need to use apache or something?
anyone who can provide me with a couple lines of working code is to me a saint!
At the moment I am using calling a named template, and passing a param into this.
I want to use this param as an argument in the Java function.
Is this possible?
example code:
     <xsl:template name="calc-age">
          <xsl:param name="dob"/>          
     <xsl:variable name="sdob" select="java:lang.String.new($dob)"/>
     <xsl:value-of select="java:toString($sdob)"/>     
     </xsl:template>

I have fixed it.
I had to call an xslt 1 function 'string' on the variable before passing it into the java function (see below).
     <xsl:template name="calc-age">
          <xsl:param name="dob"/>          
          I know that the value of the param is: <xsl:value-of select="$dob"/><br/>     
         <xsl:variable name="poo" select="$dob"/>
         <xsl:variable name="sdob" select="java:lang.String.new(string($poo))"/> 
         And here again, we try to print a variable<xsl:value-of select="$poo"/>                <br/>
         And here again, we try to print the result of the java call<xsl:value-of select="java:toString($sdob)"/>      <br/>
         and here is our variable sdob    <xsl:value-of select="$sdob"/>             
     </xsl:template>          Now this is APPARENTLY a xslt-1 function,
but the reference I had been using for this is
http://www.w3schools.com/xpath/xpath_functions.asp it is linked to by a reference that calls these xslt-2 functions.
Maybe they are mixed xslt-1 and xslt-2 functions?
How am I supposed to know?
Where is a good (plain and simple, easy to read) reference for xsl, so i know which functions are which?
Anyone got a good answer to that question?

Similar Messages

  • Newbie Help: Calling Java function from XSLT

    Hi everyone!
    I am trying to call a java function from my XSL file. like...
    <xsl:stylesheet version="1.0"
        xmlns:java="http://xml.apache.org/xslt/java"
        xmlns:fn="http://www.my.com/xslt"     
        exclude-result-prefixes="java fn">
    <xsl:variable name="embeddedpic"
    select="formData/instance/EmployeePicture" />
    <xsl:variable name="pic" select="fn:com.my.utils.ConversionUtils.base64DecodeString($embeddedpic)"/>I am getting this exception in calling the above java function from my XSLT (XalanXPathException: The function number 'http://xml.apache.org/xslt/java:com.my.utils.ConversionUtils.base64DecodeString' is not available.)I have the function lib file in my classpath but still i am getting this error. Any info is highly appreciated.
    Thanks

    Try this.
    <?xml version="1.0" ?>
    <xsl:transform version="1.0" xmlns:fn="com.my.utils" >
    <xsl:variable name="pic" select="fn:ConversionUtils.base64DecodeString($embeddedpic)"/>
    etc.
    as long as your code is in the classpath it should find it.
    Henock.

  • Is their a possibility to call SDK functions from TestStand directly?

    Hello!
    I want to call a function from the Windows SDK.
    Is this possible?
    Regards,
    Brosig
    Using TestStand 3.5 and Windows XP

    Brosig,
    sadly i dont know what the error with the pdb-file could be. but as far
    as i see from the description to the function found here, there should
    be no such dependency.
    please take a look into the "requirements"-section of the link. it
    seems that kernel32.dll is sufficient for usage of the function. and
    for myself, i never had such problems when using the kernel32.dll.....
    one problem could be the type of the parameter you are using. i know
    that there are sometimes odd issues on SDK when the parameters do not
    fit exactly the needed type.  so make sure that all strings are
    null-terminated and the buffers you pass are preallocated!
    Norbert B.
    Edit: forgot the link.....
    Message Edited by Norbert B on 12-22-2005 09:31 AM
    CEO: What exactly is stopping us from doing this?
    Expert: Geometry
    Marketing Manager: Just ignore it.

  • Calling JAVA Functions from XSLT

    Hi,
    I am trying to invoke a Java Extension Function from a XSLT. I added both the class file and the XSLT file to a folder, then zipped the entire folder and uploaded into the Archive for my Interface MApping.
    The CLASS gets loaded but the runtime engine gives an error when calling the JAVA Function.
    Here is what it says:
    Creating mapping sequence with 2 steps. --- Creating Java mapping Deliveries/stringHandler --- Creating mapping sequence with 2 steps. --- Creating XSLT mapping Deliveries/test1 --- Using MappingResolver with context URL /sapmnt/XD1/global/xi/mapping/http%3A%2F%2Fwolterskluwer%2Ecom%2Fxi%2F wk_midas_deliveries%2Ftest/cd2e6820267511d9cb52c3c5143c3524/ --- Loaded class Deliveries.stringHandler --- com.sap.aii.ibrun.server.map.MappingRuntimeException: at com.sap.aii.ibrun.server.map.MappingRuntimeException.code_STYLESHEET_OR_CLASS_NOT_FOUND(MappingRuntimeException.java:91) at com.sap.aii.ibrun.server.map.RUMappingJava.instantiate(RUMappingJava.java:168) at com.sap.aii.ibrun.server.map.RUMappingJava.execute(RUMappingJava.java:41) at com.sap.aii.ibrun.server.map.RUSequence.execute(RUSequence.java:50) at com.sap.aii.ibrun.server.map.RURunner.run(RURunner.java:58) at com.sap.aii.ibrun.server.map.RUManager.run(RUManager.java:66) at com.sap.aii.ibrun.sbeans.map.MappingRequestHandler.handleRequest(MappingRequestHandler.java:67) at com.sap.aii.ibrun.sbeans.map.MappingServiceImpl.processFunction(MappingServiceImpl.java:83) at com.sap.aii.ibrun.sbeans.map.XMappingServiceObjectImpl0.processFunction(XMappingServiceObjectImpl0.java:24) at com.sap.aii.ibrun.sbeans.map.MappingServiceKey.processFunction(MappingServiceKey.java:10) at java.lang.reflect.Method.invoke(Native Method) at com.inqmy.services.rfcengine.RFCDefaultRequestHandler.invokeBean(RFCDefaultRequestHandler.java:83) at com.inqmy.services.rfcengine.RFCDefaultRequestHandler.handleRequest(RFCDefaultRequestHandler.java:50) at com.inqmy.services.rfcengine.RFCJCOServer.handleRequest(RFCJCOServer.java:69) at com.sap.mw.jco.JCO$Server.dispatchRequest(Unknown Source) at com.sap.mw.jco.rfc.MiddlewareRFC$Server.nativeListen(Native Method) at com.sap.mw.jco.rfc.MiddlewareRFC$Server.listen(Unknown Source) at com.sap.mw.jco.JCO$Server.listen(Unknown Source) at com.sap.mw.jco.JCO$Server.run(Unknown Source) at java.lang.Thread.run(Thread.java:513) --
    Any help or suggestions to solve this problem would be greatly appreciated.
    Thanks
    A

    Hi,
    Thanks for looking into this.
    1. I have verified that the path in the zip file is correct i.e com/sap/test/stringHandler.class
    2. test1.xsl is in the root folder i.e No path.
    3. I see the Message in the stacktrace saying "Loaded Class com/sap/test/stringHandler.class " but after that I get a runtime MApping Error and it says "CLASS_NOT_FOUND".
    Can you please tell me why is this happening?
    Thanks
    A

  • Problem passing param to a java function from xslt

    HI all,
    A thousand thankyou's to any who can help me.
    Documentation is scarce, and I got to bed late last night. It has been a hard day of fruitless searching for a solution to this.
    Problem:
    Calling a named template in xsl using the with-param tag to pass in a parameter.
    attempting to call a java function, specifying that parameter as an argument.
    getting parse error:
    ERROR: 'Cannot convert argument/return type in call to method 'java.lang.String.new(java.util.Date)''
    sample code:
    calling the named template
              <xsl:call-template name="calc-age">
                   <xsl:with-param name="dob">
                        <xsl:value-of select="/FullRecord/Patient/dob"/>
                   </xsl:with-param>
              </xsl:call-template>the template itself
         <xsl:template name="calc-age">
              <xsl:param name="dob"/>          
             <xsl:variable name="date" select="java:util.Date.new()"/>
             <xsl:value-of select="java:toString($date)"/>
              <xsl:variable name="sdob" select="java:lang.String.new($date)"/>
         </xsl:template>          the error
    ERROR:  'Cannot convert argument/return type in call to method 'java.lang.String.new(java.util.Date)''
    FATAL ERROR:  'Could not compile stylesheet'
    javax.xml.transform.TransformerConfigurationException: Could not compile stylesheet
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:824)
         at com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:613)does anyone know what is wrong here?
    And if they do, where I can find examples or a reference on how this is supposed to work?
    It's driving me mad!
    Thanks all!
    svaens
    Edited by: svaens on Apr 14, 2008 9:16 AM

    ok.
    What I had pasted was wrong, But I was it was only confused because I had tried quite a few different things to get it working, and had made a mistake somewhere along the way.
    HOWEVER!!!
    This code, I believe should work, (below) but doesn't.
    the error is different, but similar.
    The call to the template remains the same, but the template itself is now different.
    What is wrong with it?
    Do i need to convert a xml document string to a java string somehow?
    template:     <xsl:template name="calc-age">
              <xsl:param name="dob"/>          
             <xsl:variable name="sdob" select="java:lang.String.new($dob)"/>
             <xsl:value-of select="java:toString($sdob)"/>        
         </xsl:template>     the error:
    ERROR:  'Cannot convert argument/return type in call to method 'java.lang.String.new(reference)''
    FATAL ERROR:  'Could not compile stylesheet'To be more clear, I am translating XML via XSL which is transformed using Java 6, and the packages:
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerFactory;

  • IFRAME in portlet question - possible to call parent function from iframe?

    From the iframe I tried to call the parent function by doing this parent.myFunc(). I got a permission denied javascript message. Just curious if anyone has successfully done this. If so please share your thoughts and comments.

    Hi,
    You will get "Persmission denied" error due to cross site scripting. Either you need to change browser settings to allow cross site scripting or you need to make sure both the URLs fall under same parent domain like both URLs ending with "*.abc.com".
    Thanks

  • Calling java functions from c++

    I want to start my program from visual c++ then, call java functions and then calling c++ function. How can i do this?

    Yet another cross-poster: [Calling java functions from c++|http://www.java-forums.org/new-java/12597-calling-java-functions-c.html]

  • Is it possible to call a java function from plsql?

    I have a plsql script which loads data in to a table. One of the fields is a notes field. I would like to use advance offerings of java to manipulate the data before inserting. Is there away I can pass the data to a java function and have it return the manipulated data?
    Thanks
    Aaron

    You can use java stored procedure to call java function from plsql.
    1. Create a java class with a static function(which will be called from plsql).
    2. Compile and load the class into database using LOADJAVA command.
    3. Create a wrapper stored procedure or function in plsql which calls the above java function.
    4. Access this plsql procedure like normal database procedure. This will invoke underlying java function in which you can do all the processing and return result.
    Refer this url for help on implementing above steps :
    http://otn.oracle.com/tech/java/jsp/pdf/developing_o8i_apps_with_plsql_and_java_twp.pdf
    Samples on java stored procedure :
    http://otn.oracle.com/sample_code/tech/java/jsp/oracle9ijsp.html
    Chandar

  • Type Mismatch error while calling a Java Function from Visual Basic 6.0...

    Hi,
    I'm having a problem in calling the Java Applet's Function from Visual Basic. First, I'm getting the handle of the Java Applet and components of it using "Document.Applets(n)" which is a HTML function. I'm calling this function from Visual Basic. My code is something like this...
    ' // Web1 is IE Browser in my Form.
    Dim Ap,Comp
    Dim Bol as Boolean
    Bol = true
    Ap = Web1.Document.Applets(0).getWindow() ' \\ Gets the Parent Window.
    Ap.setTitle("My Java Applet") ' \\ Sets the Title of the window.
    msgbox Ap.getVisibility() ' \\ This will return a Java boolean ( true or false )
    Ap.setVisibility(Bol) ' \\ Function Syntax is : void setVisibility(boolean b)
    Here in my code , i'm able to call any function that which accepts Integer or String but not boolean. So, i m facing problem with Ap.setVisibility() function. It gives me a "Type mismatch error" while executing it. Can you please tell me a way to do this from Visual Basic !
    I'm using Visual Basic 6.0, Windows 2000 , J2SDK 1.4.2_05.
    Please help me Friends.
    Thanks and Regards,
    Srinivas Annam.

    Hi
    I am not sure about this solution. try this
    Declare a variable as variant and store the boolean value in that variable and then use in ur method.
    Post ur reply in this forum.
    bye for now
    sat

  • Problem while calling java function from html

    when i tried to call a java function from html i'm getting an error
    object don't support this property.
    what could be the reason.
    This is my html.
    I got this from this forum only.
    My applet is accessing the system property "user.home".
    I ran it in IE
    <DIV id="dvObjectHolder">Applet comes here</DIV>
    <br><br>
    <script>
    if(window.navigator.appName.toLowerCase().indexOf("netscape")!=-1){ // set object for Netscape:
         document.getElementById('dvObjectHolder').innerHTML = " <object ID='appletTest1' classid=\"java:test.class\"" +
    "height=\"0\" width=\"0\" onError=\"changeObject();\"" +
              ">" +
    "<param name=\"mayscript\" value=\"Y\">" +
    "<param name=\"archive\" value=\"sTest.jar\">" +
    "</object>";
    }else if(window.navigator.appName.toLowerCase().indexOf('internet explorer')!=-1){ //set object for IE
         document.getElementById('dvObjectHolder').innerHTML = "<object ID='appletTest1' classid=\"clsid:8AD9C840-044E-11D1-B3E9-00805F499D93\"" +
              " height=\"0\" width=\"0\" >" +
              " <param name=\"code\" value=\"test.class\" />" +
         "<param name=\"archive\" value=\"sTest.jar\">" +
              " </object>"
    </script>
    <LABEL id="lblOutputText">This text will be replaced by the applet</LABEL>
    <BR>
    <input value="Javascript to java" type=button onClick="document.appletTest1.fromJavaScript()">

    I tried this example using the repy given to an earlier post.
    But its not working with me.
    What i did in addition was adding plugin.jar to classpath to import netscape.javascript.*;
    Let me add some more details
    1) I'll add the stack trace
    2) my java progrma
    3) batch file to sign the applet.
    1) This is the stack trace i don't know whether u will undertand this
    load: class test.class not found.
    java.lang.ClassNotFoundException: test.class
         at sun.applet.AppletClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at sun.applet.AppletClassLoader.loadCode(Unknown Source)
         at sun.applet.AppletPanel.createApplet(Unknown Source)
         at sun.plugin.AppletViewer.createApplet(Unknown Source)
         at sun.applet.AppletPanel.runLoader(Unknown Source)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.FileNotFoundException: C:\FastranJava\AppletObject\bin\test\class.class (The system cannot find the path specified)
         at java.io.FileInputStream.open(Native Method)
         at java.io.FileInputStream.<init>(Unknown Source)
         at java.io.FileInputStream.<init>(Unknown Source)
         at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
         at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
         at sun.applet.AppletClassLoader.getBytes(Unknown Source)
         at sun.applet.AppletClassLoader.access$100(Unknown Source)
         at sun.applet.AppletClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         ... 10 more
    Exception in thread "Thread-5" java.lang.NullPointerException
         at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
         at sun.plugin.AppletViewer.showAppletException(Unknown Source)
         at sun.applet.AppletPanel.runLoader(Unknown Source)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    2) Java Program
    import netscape.javascript.*;
    import java.applet.*;
    public class test extends Applet
         private JSObject win;
         private JSObject outputLabel;
         private boolean buttonFromJavaClicked=false;
         checkJavaScriptEvent evt=new checkJavaScriptEvent();
         public void init()
              try
                   evt.start();
                   win=JSObject.getWindow(this);
                   outputLabel=(JSObject)win.eval("document.getElementById('lblOutputText')");
                   outputLabel.setMember("innerHTML", "<center><h1>From Init<br>Your Home directory" + System.getProperty("user.home") + "</h1></center>");
              catch(Exception e)
                   e.printStackTrace();
         public void fromJavaScript()
              buttonFromJavaClicked=true;          
         public void fromJavaScript2()
              System.out.println("Started Form JavaScript2");
              try
                   String strLbl="<center><h1>From JavaScript<br>Your Homedir:" + System.getProperty("user.home") + "</h1></center>";
                   outputLabel.setMember("innerHTML", strLbl);
              catch(Exception e)
                   e.printStackTrace();
         class checkJavaScriptEvent extends Thread
              public void run()
                   while(true)
                        if(test.this.buttonFromJavaClicked)
                             System.out.println("OK buttonfromjava is true");
                             test.this.buttonFromJavaClicked=false;
                             fromJavaScript2();
                        try
                             Thread.sleep(3000);
                        catch(Exception e)
                             e.printStackTrace();
    3) Batch file
    del *.cer
    del *.com
    del *.jar
    del *.class
    javac -classpath ".;C:\Program Files\Java\jre1.5.0_06\lib\plugin.jar" test.java
    keytool -genkey -keystore harm.com -keyalg rsa -dname "CN=Harm Meijer, OU=Technology, O=org, L=Amsterdam, ST=, C=NL" -alias harm -validity 3600 -keypass password -storepass password
    jar cf0 test.jar *.class
    jarsigner -keystore harm.com -storepass password -keypass password -signedjar sTest.jar test.jar harm
    del *.class

  • How to call java function from PL/sql in oracle applications

    I am trying to call a java function from plsql procedure. Can any one explain how to call java function, and in which directory I have to store my java function in oracle applications. Do I need to register that java function from Application developer.
    Thanks
    Kranthi

    http://www.oracle.com/technology/tech/java/jsp/index.html
    Good Luck,
    Avi.

  • Calling a java function from xquery

    Hello,
    I'm pretty new to ODSI and xquery, so forgive me if what I'm asking is too trivial, but I need to find a way to call a java function from inside xquery. I know xquery can do this through external functions, but can't find any example on how the query prolog declaration should be, nor how the function should look like. Could someone enlighten me?
    Thanks,
    Pedro Ivo

    You can do this 2 ways that I know of (Mike probably has more ideas too)
    1. Register an inversion function:
    [How to use an inversion function|http://download.oracle.com/docs/cd/E13167_01/aldsp/docs32/dsp32wiki/Using%20Inverse%20Functions%20to%20Improve%20Query%20Performance.html]
    2. Create a physical data service based on a java function. I have used this approach for both custom JDBC database operations and straight Java processing, with pretty good results.
    Good luck,
    Jeff
    Edited by: jhoffmanme on Apr 14, 2010 9:57 AM

  • Call Java function from multithreaded VC++ application

    Friends, I want to call Java function from two threads of a single VC++ application. I can call it from single thread but when I call it from another thread also, JNI_CreateJavaVM() replies with an error.
    Please......help me

    Your posting is ambiguous. My impression is that you have two threads, both trying to create a java VM?

  • JCo Outbound( calling Java Function from ABAP )

    HI,
    I want to call a JAVA function from ABAP.I have installed the JCo toolkit and included the sapjco.jar file in the classpath of my system.
    When i execute the program(Example5.java,provided with sapjco.zip) from the command prompt,it is working fine,the server listens to the calls made from ABAP via RFC destination.
    But if i copy the same program in NWDS in a JAVA project,to run it from there as JAVA application,after including the sapjco.jar file in the project JAVA build path,i get the following error,marked by a red cross ,at the head of the program,even before i run it.
    <b>This compilation unit indirectly references the missing type com.sap.jdsr.writer.DsrIPassport (typically some required class file is referencing a type outside the classpath)</b>
    What changes do i need to make,to run it from NWDS?
    I tried to include the sapjcorfc.dll file along with the sapjco.jar in the java build path,but it doesn't help.
    Please tell how to solve this issue?
    Regards,
    Siddhartha

    hello sid,
    which jco version are you using?
    are you using the same jco lib when running in command
    line and in nwds?
    if you are, try checking the order of the your classpath.
    your jco lib (which you are using in command line) should
    come first in order prior to the default libraries in your project.
    regards
    jo

  • Call a Java Function From Abap

    Hi, I need to call a java function from ABAP,  I have a WAS 640 to deploy the module.
    I have found this tutorial...
    [ABAP calls Java via RFC|/people/thorsten.franz3/blog/2008/11/21/abap-calls-java-via-rfc-1-introduction]
    The problem is that it uses a newer version of WAS and it implements EJB 3.0 wich only works on Java 5, but my WAS has java 1.4.2.
    Anyone knows how to adapt this Blog to a WAS 640 version ?
    Or Perhaps there is another way of doing this, maybe publishing my function as a web service.
    Regards.
    Mariano.

    Why don't you expose your Java functionality as a Web Service and consume it in ABAP program. That should be much easier and the web service can be used in other places as well.
    Best regards,
    Ritesh Chopra

Maybe you are looking for

  • ZIP attachments in PDF file

    How can ZIP files be opened from a PDF file using Preview. First, how can you see attachments within Preview, and then, how can it be opened.

  • Problem in QUICK TUNE advisor

    begin DBMS_ADVISOR.QUICK_TUNE(DBMS_ADVISOR.SQLACCESS_ADVISOR,'my task','select * from sadat.test'); end; This code give these errors: ORA-13600: error encountered in Advisor QSM-00784: the table SH.% referenced in the list SH.% is invalid for paramet

  • Using 2 headsets at one time

    I was wondering if it's possible to use a headset in the audio output and a usb headset at the same time and/or 2 usb headsets at one time? If the osx doesn't support this then is there an app that does? thanks

  • Set Flag Automatically in Transaction BP

    Hello, We are in SRM 4.0 , classic scenario. We have a requirement to create a LSMW to set a flag "Central Block" under status tab for selected Business Partner. We tried this requirement using LSMW, Recordings. But it does not work. Do we have any B

  • PI7.11 - Integration Directory

    I'm trying using PI7.11.  Trying to create this scenario, ECC<-(SOAPadapter)->PI<-- (JDBCadapter)----->OracleTable. I've got all the design objects built correctly along with the SLD products and all. I'm in ID now where I created 2 business systems