Calling java instance methods in XSLT stylesheet

HI
I know this has been answered in this forum but I cnanot get it to work.
Before calling the transform() method on my transformer instance I do the following
transformer.setParameter( "Confirm", confirm)confim is an instance of one of my own classes. I want to get the
XSLT stylesheet to call a method on this object. The method sig is
public void setTitle(String title)Accordingly in my stylesheet I do the following
<xsl:param name="Confirm"/>having already declared the java namespace in my stylesheet element as xmlns:java="java", and later on call the setTitle method
<xsl:value-of select="java:setTitle($Confirm,$Title)/>where $Title is another var generated in the XSLT.
This should work, right? Well I get an error
'The first argument to the non-static Java function 'setTitle' is not a valid object reference.'But it is as I can do this
<xsl:value-of select="$Confirm"/>Thanks
Mark

Hi !
I've being trying to use a java class into xsl but without success.
If anybody can help me to no how do I have to organize the files (.class, .xsl)????
My organization is like this
c:
WEBAPP
WEB-INF (here I have the .xml and .xsl)
classes
com
example (here I have the .class)
And I use it as follows:
--------------------------------------xslextension_prueba.XSL------------------ ---------------------------
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:java="java"
extension-element-prefixes="java"
version="1.0">
<xsl:output method="html"/>
<xsl:template match="/">
<html>
<body bgcolor="#FFFFFF">
<h2>The smoking calendar</h2>
<h3>
<xsl:value-of select="java:Date.new()"/>
</h3>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
--------------------------------------------XML-------------------------------- ----
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="xslextension_prueba.xsl"?>
<articles>
<article>
<title>Using Web Services</title>
<author>T. Cowan</author>
<date>11/30/01</date>
<text>
content of article.
</text>
</article>
<article>
<title>Java May Be Just a Fad</title>
<author>J. Burke</author>
<date>08/15/95</date>
<text>
content of article.
</text>
</article>
</articles>
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!AND I GET THIS ERROR!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
E The URI java does not identify an external Java class
THANKS FOR YOUR HELP......

Similar Messages

  • Calling Java Android code from XSLT

    I am trying to get an XSLT stylesheet to work that invokes Java code at certain points during execution (used to parse RDFa). You can find a very simple example of such code below:
    <?xml version="1.0" encoding="UTF-8"?>
    <stylesheet
    xmlns:xsl ="http://www.w3.org/1999/XSL/Transform" version="1.0"
    xmlns ="http://www.w3.org/1999/XSL/Transform"
    xmlns:xalan="http://xml.apache.org/xalan"
    xmlns:java="http://xml.apache.org/xalan/java"
    exclude-result-prefixes="java" >
    <xsl:template match="/">
    <value-of select="java:android.xslt_test.XSLTTest.testing()"/>
    </xsl:template>
    </stylesheet>
    Although this XSLT calls the specified method for a Java desktop application, it doesn't do anything in an Android application (no methods are called and the transformer simply returns the original document). After I configured the Transformer instance with a custom ErrorListener subclass instance (via aTransformer.setErrorListener()), I get a NullPointerException (packaged as a TransformerException) when the above XSLT code is parsed. This error does not occur for "normal" XSLT sheets (these are parsed correctly on Android).
    Any ideas on why this doesn't work? Do I need to use another prefix / namespace for Android applications? I've spent quite some time looking online for a solution, but couldn't find any..
    Thanks,
    William

    The question really comes down to "can I call a server-side object from the client side?"
    The answer is "not directly". You can call a client-side JavaBean from JavaScript (e.g. when you use <jsp:plugin/> to embed a JavaBean in the HTML, you can call that from the JavaScript on the client-side.) You can call a server-side JavaBean using server-side code only.
    You can probably set up a framework to cause a function on the client to submit to a servlet which changes the bean on the server, but you can't just call it directly.

  • Use Java to process the XSLT stylesheet

    Background:-
    I used Java to design a very simple Interface, which was composed of two components, one is an editable comboBox, the other is a button. What I want to achieve is selecting the value in the combobox and clicking the button, then it will achieve the relevant transformation process against the value selected from the comboBox.
    Implementation:-
    The transformation process is to extracting a set of information about a certain bird from an XML document, which contains many birds' information, to form a new XML document of one bird. The bird that I want to transform is listed in the comboBox and can be selected there. I use the Java to control the transformation process. My design is: I use Java programme to read the selected comboBox's value (bird name) and pass this value to the XSLT stylesheet, which is used to transform the XML document to a new XML document. What I have implemented: The Java programme has successfully controlled the transformation process, but I have defined in the XSLT stylesheet the bird name in advance. So the transformation is limited.
    What I want:-
    What I want is the transformation process will be carried out based on the value (bird name) read from the comboBox on the interface. And I hope to use Java to achieve this design!
    XSLT stylesheet code:-
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
    <xsl:template match="node()">
         <xsl:apply-templates/>
    </xsl:template>
    <xsl:template match="class[own-slots/own-slot/entry/value = 'Barn_swallow']">
         <xsl:copy-of select="."/>
    </xsl:template>
    </xsl:stylesheet> I am very appreciated if you can provide me some helps kindly!
    Thanks a lot! Waiting for your nice suggestions!
    David

    I mean, you can find the bird name(Barn_swallow) in my
    attached XSLT stylesheet code. This name was actually
    defined in advance. What I want to perform now is to
    use the Java program to get the bird name from the
    comboBox (you have gave out the method) and pass it to
    the XSLT(actually needed to implement by Java), then
    continue to use the Java programe to achieve the
    transformation process (this step, I think, has been
    achieved.) Obviously, how to perform the second step
    "pass it to the XSLT" is the current task!What can you do already? Can you get a Transformer object from a TransformerFactory? If so, then simply call its setParameter("bird", "Barn Swallow") method. You'll have to declare a top-level xsl:param element whose name is "bird" in your XSL transformation, which you can then use as if it were a variable.

  • How to call a instance method without creating the instance of a class

    class ...EXCH_PRD_VERT_NN_MODEL definition
    public section.
      methods CONSTRUCTOR
        importing
          value(I_ALV_RECORDS) type ..../EXCH_VBEL_TT_ALV
          value(I_HEADER) type EDIDC .
      methods QUERY
        importing
          I_IDEX type FLAG
          i_..........
        returning
          value(R_RESULTS) type .../EXCH_VBEL_TT_ALV .
    Both methods are instance methods.
    But in my program i cannot created instance of the class unless i get the results from Query.
    I proposed that Query must be static, and once we get results we can create object of the class by pasing the result table which we get from method query.
    But i must not change the method Query to a static method.
    Is there any way out other than making method Query as static ?
    Regards.

    You can't execute any instance method without creating instance of the class.
    In your scenario, if you don't want to process your method of your class, you can check the instance has been created or not.
    Like:
    IF IT_QUERY IS NOT INITIAL.
      CRATE OBJECT O_QUERY EXPORTING......
    ENDIF.
    IF O_QUERY IS NOT INITIAL.
    CALL METHOD O_QUERY->QUERY EXPORTING....
    ENDIF.
    Regards,
    Naimesh Patel

  • How do I 'call' external instance methods?

    I want to send a message from a Controller to another Class  to execute a method.  Inside the controller, I typed my message:     
                    [[MemoryContent]  PopulateMemory];
    What I think I am doing here is telling it to go to the MemoryContent class and execute the method called PopulateMemory.  The compiler insists that I make PopulateMemory into a class method.  But when I do that, I cannot deal with the instance methods and instance variables that I need.  What am I missing?

    Assuming you are following recommended Cocoa naming conventions, the fact that MemoryContent has an initial cap means it is a class, not an instance of a class. So the compiler error is correct. If you want to use an instance method, first create an instance of the class, then call the method on the instance.
    Your method name PopulateMemory should probably not have an initial cap.
    So you would typically see something like this.
    MemoryContent *memoryContent = [[MemoryContent alloc] init];
    [memoryContent populateMemory];
    Of course if the class instance already exists, don't create another one. Instead get a reference to the existing instance.

  • Unable to call Java class method within Embedding Java Activity in BPEL

    Hi ,
    I have written Java Class named 'Class3' .
    When I am creating and trying to call these classes whithin Embedding Java Activity , compile time error is coming. Compiler is not finding class . Error message is like this one.
    uildfile: C:\Oracle\Middleware\jdeveloper\bin\ant-sca-compile.xml
    scac:
    [scac] Validating composite : 'C:\JDeveloper\mywork\Application7\Embedded15\composite.xml'
    [scac] C:\JDeveloper\mywork\Application7\Embedded15\SCA-INF\bpel\BPELEmbedded15\src\orabpel\bpelembedded15\ExecLetBxExe0.java:73: cannot find symbol
    [scac] symbol : class Class3
    [scac] location: class orabpel.bpelembedded15.ExecLetBxExe0
    [scac] C:\JDeveloper\mywork\Application7\Embedded15\SCA-INF\bpel\BPELEmbedded15\src\orabpel\bpelembedded15\ExecLetBxExe0.java:73: cannot find symbol
    [scac] symbol : class Class3
    [scac] location: class orabpel.bpelembedded15.ExecLetBxExe0
    [scac] Note: C:\JDeveloper\mywork\Application7\Embedded15\SCA-INF\bpel\BPELEmbedded15\src\orabpel\bpelembedded15\BPEL_BIN.java uses unchecked or unsafe operations.
    [scac] Note: Recompile with -Xlint:unchecked for details.
    [scac] FATAL_ERROR: location {ns:composite/ns:component[@name='BPELEmbedded15']}(20,36): Failed to compile bpel generated classes.
    [scac] failure to compile the generated BPEL classes for BPEL process "BPELEmbedded15" of composite "default/Embedded15!1.0"
    [scac] The class path setting is incorrect.
    [scac] Ensure that the class path is set correctly. If this happens on the server side, verify that the custom classes or jars which this BPEL process is depending on are deployed correctly. Also verify that the run time is using the same release/version.
    [scac]
    BUILD FAILED
    C:\Oracle\Middleware\jdeveloper\bin\ant-sca-compile.xml:264: Java returned: 1 Check log file : C:\JDeveloper\mywork\Application7\Embedded15\SCA-INF\classes\scac.log for errors
    Total time: 8 seconds
    I am creating Class3 directly in Application Resources folder indide Project Folder in Jdeveloper without creating any package. Code of the class is .......
    public class Class3 {
    public Class3() {
    super();
    public String getValue(){
    return "BBBBBBB";
    Can any one help?
    Regards
    Yogendra Rishishwar
    9867927087

    Hi ,
    In your java project frm jdev..right click and choose general and then choose deployment profiles and then choose Jar ..and then give some appropriate name(abc) and then click ok.
    Then under resources file u get a abc.deploy file right click and say deploy to jar ..u will find the jar in that director.Now include this jar in your prjct libraries.
    have a look at the link http://niallcblogs.blogspot.com/search/label/embedded%20Java

  • Calling a java static method from javascript

    I am running into issue while calling a java static method with a parameter from javascript. I am getting the following error. Any help is greatly appreciated.
    Thx
    An error occurred at line: 103 in the jsp file: /jnlpLaunch.jsp
    pfProjectId cannot be resolved to a variable
    =================================================
    // Java static method with one parameter
    <%!
    public static void CreateJnlpFile(String pfProjectId)
    %>
    //Script that calls java static method
    <script language="javascript" type="text/javascript">
    var pfProjectId = "proj1057";
    // Here I am calling java method
    <%CreateJnlpFile(pfProjectId);%>
    </script>
    ===================================================
    Edited by: 878645 on Mar 6, 2012 11:30 PM

    Thanks, Got what you are telling. Right now I have one jsp file which is setting the parameter 'pfProjectId' and in another .jsp I am retrieving it. But I am getting null valuue
    for the variable. I am wondering why I am getting null value in the second jsp page?.
    Thx
    ====================================================================
    <script language="javascript" type="text/javascript">
    // Setting parameter pfProjectId
    var pfProjectId = "proj1057";
    request.setParameter("pfProjectId", "pfProjectId");
    </script>
    // Using Button post to call a .jsp that creates jnlp file
    <form method=post action="CreateJnlpFile.jsp">
    <input type="submit" value="Create JNLP File">
    </form>
    //Contents of second .jsp file CreateJNLPFile.jsp
    String pfProjectId = request.getParameter("pfProjectId ");
    System.out.println( "In CreateJnlpFile.jsp pfProjectId " + pfProjectId );
    =======================================================

  • ***Calling Java finctions in XSLT MApping

    Hi All,
    How to  call java mapping functions in XSLT.I have created Value mapping function in java,want to call the same through XSLT.
    could you provide me  general XSLT prdefined functions with explanations that may be used commonly.
    Thanks,
    Srinivasa

    Hi Srinivas,
    Please see these blogs:
    /people/pooja.pandey/blog/2005/06/27/xslt-mapping-with-java-enhancement-for-beginners
    /people/sreekanth.babu2/blog/2005/01/05/design-time-value-mappings-in-xslt
    /people/kulwinder.grewal/blog/2009/08/21/xslt-runtime-value-mapping-from-integration-directory-using-xivmserviceclass
    /people/kulwinder.grewal/blog/2009/08/21/java-runtime-value-mapping-from-integration-directory-using-xivmserviceclass
    Regards,
    ---Satish

  • Calling Java in XSLT

    Hi,
    I am using the following blog to create and XSLT mapping and trying to call Java code from within XSLT. The only issue I am having is that I am not sure where should I put the .java and .class files. If I include both the files in a seperate folder, then where should I place the imported archived zip folder? eg: if my XSLT is test_xslt.zip and my java code zip folder which has the .java and .class files is com.util.zip. Now where should i place the imported archived folder com.util.zip so that the XSLT can call this Java code.
    Useful XSLT mapping functions in SAP XI/PI

    Hello,
    >>Now where should i place the imported archived folder com.util.zip so that the XSLT can call this Java code
    To call a java function inside a XSLT mapping, u have to make sure that the java IA (.class file) should be in the same or underlying SCV of the XSLT - That's the only dependency.
    Thanks
    Amit Srivastava

  • Calling Instance Method in a Global Class

    Hi All,
    Please can you tell me how to call a instance method created in a global class in different program.
    This is the code which I have written,
    data: g_cl type ref to <global class>.
    call method g_cl -> <method name>
    I am not able to create Create object <object>.
    It is throwing the error message " Instance class cannot be called outside...."
    Please can anybody help me..
    *Text deleted by moderator*
    Thanks
    Sushmitha

    Hi susmitha,
    1.
    data: g_cl type ref to <global class>.
    2.
    Create object <object>.
    3.
    call method g_cl -> <method name>.
    if still you are getting error.
    then first check that method level and visibility in se24.
    1.if  level is static you can not call it threw object.
    2. if visibility is protected or private then you can not  call it directly.
    If still you are facing same problem please paste the in this thread so that i can help you better.
    Regards.
    Punit
    Edited by: Punit Singh on Nov 3, 2008 11:54 AM

  • How to call Instance Methods and set property values in BAPI?

    In Project systems, for the three business objects viz.
    Network, ProjectDefinition and WBS, there are two kinds of methods which are available : class methods and instance methods. We have tried calling some instance methods, for instance, BAPI_PROJECTDEF_GETDETAIL to get details pertaining to a project. While importing this BAPI, it shows two elements for mapping i.e. Current Internal Project(string) and Current External Project(string). We supplied these values for an existing project. Upon running this call through an XML client at our end, it
    returned an error "Module Unknown Exception". This general message is present on every instance method thus far. Upon searching in BAPI Explorer for Project System->ProjectDefinition->GetDetail, we found that this BAPI didn't take any input parameter.
    Following message was displayed in BAPI Exlorer for this BAPI:
    "... Obligatory import parameters are the external and internal keys CURRENTEXTERNALPROJE and CURRENTINTERNALPROJE of the project definition.The system reads parameters contained in the structure
    BAPI_PROJECT_DEFINITION_EX ..."
    i) How to supply the values of Obligatory import parameters.
    ii) What are the possible causes of this exception.
    iii) How to call an instance method. We are using same mechanism for calling class as well as instance methods so far, we have been to call only class level methods successfully. Is there anything special that we
    need to do to call instance methods.

    Hi,
    what version is the SAP PS running?  If WebAs or higher,  create an inbound synch interface containing your two parameters in the request structure and as many as you require in your response structure.  Generate an Inbound ABAP proxy, where you can plug in some code, i.e. create and instantiate an object of the required type and make the call to the BAPI.
    If SAP PS on lower than WebAs, then create a wrapper function module and make it RFC enabled.  Then plug your code in here and do the same thing.
    Watch out for commits!
    Cheers,
    Mark

  • Calling java from scripting

    Hello,
    I would like to integrate some scripting capability in my web application.
    The main purpose is to cover the following scenario :
    - I develop a web app with JSP technology, packaged in a MyAPP.WAR file containing my application and another file (MyCustomer.RAR?) containing installation specific informations. I want the MyApp.WAR to be the same for all my customers, just having the RAR file specific to each customer (installation).
    - In this ressource file, there could be some scripting functions that will be called from my JSP Pages to change the default presentation with some customer particular informations.
    Those informations would be extracted from my java data model. The purpose is to enable the customer to code some little script, and to avoid coding those in Java.
    The question I have on that are :
    1/ is it possible to call java instances from scripting language (I read on apache that the answer was yes for some of them), but I would like to know if javascript can do that.
    2/ Can I recover the "result" of the script in JSP ?
    An example :
    1/ The class containing a marvellous property
    class MyClass {
    public String myProperty;
    2/ The JSP page :
    <stlLib:callScript(Customer.RAR, "ScriptToCall",anInstance) />
    <stlLib:getResult ???>
    3/ A user script (pseudo-code)
    Customer 1 :
    Function ScriptToCall(object) {
    variable iwanttoshowsquareroot;
    iwanttoshowsquareroot = squareroot(object.myProperty);
    return iwanttoshowsquareroot ;
    Customer 2 :
    Function ScriptToCall(object) {
    variable mychoiceisdifferent;
    mychoiceisdifferent= object.myProperty / 2;
    return mychoiceisdifferent;
    According to what ScriptToCall looks like the result on page would be different
    Thanks in advance for your advises
    Olivier.

    1) The script will be running in the browser, not the server, yes? So in Netscape you can load Java objects via Javascript, but IE doesn't seem to support this. Although in either, you can call methods on an applet in the page. But you can't call a JS function from the Java code in the JSP page, since that is only executed on the server.
    2) Only if the "result" is submitted back to the server.

  • Can we call java jar from ODI?

    Hi All,
    Can we call java jar from ODI? if yes please suggest how?
    Regards,
    Satish

    This is an excellent article from Uli.
    One reason, I dont like this approach is that is mandates to copy the .jar file to the driver folder and restart the agent.
    Think of a scenario where there are several developers in love with Java and want to place the jars in the drivers directory.
    This is a maintenance nightmare for the admin and would clutter up the drivers directory.
    Find here the way to invoke Java jar methods
    http://askankit.blogspot.com/2010/09/call-java-jar-methods-from-odi.html

  • How to call Java method from XSLT??

    Hi All,
    Jdev 11.1.1.3.0
    I have a requirement to implement that, I have to call Java method from XSLT. Could anyone please suggest to implement that??
    Thanks,
    Santosh M E

    As pointed by others, you must expose your method as a custom function, registering with JDeveloper (for development time) as well as with SOA Suite (for runtime).
    In the link below you will find a simple step by step example:
    https://blogs.oracle.com/reynolds/entry/building_your_own_path
    Regards,
    Luis F. Heckler

  • Are DLL methods called as instance or static methods from Java ?

    Hi,
    I have only a small question.
    When I call a C++ DLL method from Java using JNI, do I instantiate it like an object method or is it called as a static method ?
    I am asking you this because I will use servlets (Java 1.2.2) to call a DLL. These servlets may run concurrently in any moment, and I pass some data to this DLL. I want to know if there is any possibility of this data becoming corrupt, because of one concurrent servlet rewriting the data another servlet has passed.
    Thanks and regards.

    The question is not specific enough.
    Methods in C/C++ can be qualified with the following forms:
    -global (C/C++)
    -static member(C++ class method)
    -instance member(C++ class method)
    Since you didn't provide your code I couldn't possible determine which of the above you are using, but presumably you know.
    On the other hand a java native method is either static or non-static depending on how you defined it in the class. Once again without the code there is no way to say and presumably you already know this.
    The context of the methods is the same context that a similar servlet method has. But naturally in C/C++ is is easy to circumvent the context - for example by using a global variable.
    Data in C/C++ can always become corrupt and in the vast (all?) cases it is because something is wrong in the C/C++ code. Like a pointer that is not initialized, or a pointer used after it is free'd. Or writing past the end of a buffer, or writing before the beginning of a buffer.

Maybe you are looking for

  • My ex had set up a dual apple id, which i didn't know about. deleting locked items.

    does this mean that every timed I synced my device he received all my stuff/ photos and things from the last year? I am concerned. Also does it mean that he has a copy on his icloud? I had renamed my computer but his id was still there, so when I add

  • Domains and Logical Types in Data Modeler

    Been out of serious design work for a long time. Can someone provide a good pointer to descriptions on Domains and Logical Types and presented in the Data Modeling tool? For instance I am having trouble tracking the following distinctions: Domain Log

  • Two screens although there is no second connected

    Hi, I recently discovered that my 2008 Mac Pro (connected to a 30" Apple Display, Mountain Lion 10.8.4) shows two screens when I log in with screen sharing. I then tested it on the machine itself and yes, there was a second screen (800x600) in the up

  • SOAP vs RFC - performance and pros and cons

    Hi, I have been playing around with the SAP .NET Connector 2.0 between an ASP.NET 1.1 application and SAP passing in either SOAP or RFC connection strings to the proxy classes as a proof of concept for some integration work required for our existing

  • GetEffectiveUser

    I have installed weblogic on my redhat 6.2, and when I try to start the server, I have the follwing exception. I lauch it as root, there is a weblogic user, I don't know what is the problem. The WebLogic Server did not start up properly. Exception ra