How to call external java functions in XSLT Mapping Programs

Hi All,
I am unable to call java programs in XSLT MAPPING.
I tried by following the blog...but getting error :
XSLT Mapping With JAVA Enhancement ( For Beginners)
I need some input from you all.
Waiting For quick reply.
Rgds Somu.

i wrote the code...
and getting error in interface mapping..
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:MyLib="java:datetime.DateandTime">
     <xsl:template match="/">
          <Order DocType="OrderCreate" Version="2.0.2">
               <Header>
                    <RequestingDocumentIdentifier>
                         <DocumentIdentifier>
                              <xsl:value-of select="concat('IDOC',//EDI_DC40/DOCNUM)"/>
                         </DocumentIdentifier>
                    </RequestingDocumentIdentifier>
                    <RequestingDocumentDateTime>
                         <DateTime DateTimeQualifier="On">
                                        <xsl:if test="function-available('MyLib:getDateValue')">
                   <xsl:value-of select="MyLib:getDateValue()"/>                   
  </xsl:if>
                                    </DateTime>
                    </RequestingDocumentDateTime>
                    <From>
                         <PartnerInformation>
                               <PartnerName>BASF SA</PartnerName>
                                <PartnerIdentifier Agency="AssignedByBASF">
                                 <xsl:value-of select="//E1EDK14[QUALF='014']/ORGID"/>
                                </PartnerIdentifier>
                         </PartnerInformation>
                    </From>
                    <To>
                    <PartnerInformation>
                         <PartnerName>BASF CORP CHEM DIV</PartnerName>
                         <PartnerIdentifier Agency="D-U-N-S">001307032</PartnerIdentifier>
                    </PartnerInformation>
               </To>
               </Header>
          </Order>
     </xsl:template>
</xsl:stylesheet>

Similar Messages

  • How to call external Java code from Animate project?

    I am creating a trainer using Animate that needs to interface with an aircraft model written in Java.  Is there a way to call external Java functions from Animate?
    Thanks!

    you can import external java files by yepnope
    yepnope({nope:[
                                  'your java script file address.js',
                             ],complete: init});
    function init() {
    codes that work with your js file can be write in here
    Zaxist

  • How to call this Java function?

    Hi
    I imported the following java function in oracle forms 10g Rel. 2:
    PACKAGE BODY WorkDocumentWsStub IS
      -- DO NOT EDIT THIS FILE - it is machine generated!
      args   JNI.ARGLIST;
      -- Constructor for signature (Ljava/lang/String;)V
      FUNCTION new(
        a0    VARCHAR2) RETURN ORA_JAVA.JOBJECT IS
      BEGIN
        args := JNI.CREATE_ARG_LIST(1);
        JNI.ADD_STRING_ARG(args, a0);
        RETURN (JNI.NEW_OBJECT('ch/mv/wox/WorkDocumentWsStub', '(Ljava/lang/String;)V', args));
      END;
      -- Constructor for signature (Lorg/apache/axis2/context/ConfigurationContext;Ljava/lang/String;)V
      FUNCTION new(
        a0    ORA_JAVA.JOBJECT,
        a1    VARCHAR2) RETURN ORA_JAVA.JOBJECT IS
      BEGIN
        args := JNI.CREATE_ARG_LIST(2);
        JNI.ADD_OBJECT_ARG(args, a0, 'org/apache/axis2/context/ConfigurationContext');
        JNI.ADD_STRING_ARG(args, a1);
        RETURN (JNI.NEW_OBJECT('ch/mv/wox/WorkDocumentWsStub', '(Lorg/apache/axis2/context/ConfigurationContext;Ljava/lang/String;)V', args));
      END;
      -- Constructor for signature ()V
      FUNCTION new RETURN ORA_JAVA.JOBJECT IS
      BEGIN
        args := NULL;
        RETURN (JNI.NEW_OBJECT('ch/mv/wox/WorkDocumentWsStub', '()V', args));
      END;
    -- Method: searchDocuments (Lch/mv/wox/WorkDocumentWsStub$SearchDocuments;)Lch/mv/wox/WorkDocumentWsStub$SearchDocumentsResponse;
      FUNCTION searchDocuments(
        obj   ORA_JAVA.JOBJECT,
        a0    ORA_JAVA.JOBJECT) RETURN ORA_JAVA.JOBJECT IS
      BEGIN
        args := JNI.CREATE_ARG_LIST(1);
        JNI.ADD_OBJECT_ARG(args, a0, 'ch/mv/wox/WorkDocumentWsStub$SearchDocuments');
        RETURN JNI.CALL_OBJECT_METHOD(FALSE, obj, 'ch/mv/wox/WorkDocumentWsStub', 'searchDocuments', '(Lch/mv/wox/WorkDocumentWsStub$SearchDocuments;)Lch/mv/wox/WorkDocumentWsStub$SearchDocumentsResponse;', args);
      END;I call the function searchDocuments with the following plsql-code in a when-button-pressed trigger:
    DECLARE
    raisedException      ora_java.jobject;
    jo           ora_java.jobject;
    jo1          ora_java.jobject;
    arr           ora_java.jarray;
    BEGIN
    message('1');
    jo  := WorkDocumentWsStub.new;
    message('2');
    arr := WorkDocumentWsStub.searchDocuments(jo,jo1);
    message('3');
    EXCEPTION
      --check for ORA-105100
      WHEN ORA_JAVA.JAVA_ERROR THEN
        :test.msg := 'Unable to call out to Java, ' ||ORA_JAVA.LAST_ERROR;
      --check for ORA-105101
      WHEN ORA_JAVA.EXCEPTION_THROWN THEN
        raisedException := exception_.new(ORA_JAVA.LAST_EXCEPTION);
        BEGIN
          :test.msg := 'Exception: '||Exception_.toString(raisedException);
        EXCEPTION
          WHEN ORA_JAVA.JAVA_ERROR THEN
            :test.msg := 'Unable to call out to Java, ' ||ORA_JAVA.LAST_ERROR;
        END;
    END;The trigger allways raised with the following exception: Exception: java.lang.Exception: java.lang.NullPointerException
    Thanks for any help in advance!
    Niels

    I would suggest putting the calls to WorkDocumentWsStub.new and WorkDocumentWsStub.searchDocuments(jo,jo1) in separate exception blocks so you know which one generates the nullpointerexception.
    Also, shouldn't you provide parameters to the "new" function? What should the searchDocuments function search for then? There is no document after all.

  • How to use  Advance java function in graphical mapping in XI 2.0?

    Hi,
    currently I am using a simple java function to make an RFC call to R3 system.
    I want to avoid making connection for each lookup. Instead I want to make a single connection for whole message queue and get the corresponding values in some array or container object.
    please suggest a solution.
    I think this is possible using Advance java function, but I am not able to find any example on using Advance java function at help.sap.com.
    thaks in advance.

    Hi!!!
    I'm not sure if I understood you well.
    Do you want to preload some data into your structures in the memory and keep them there so you don't need to make a new connection during processing the whole message or every message?
    In my opinion you can cache some data during processing a message, but it's impossible to cache some data between processing messages.
    If you write your java mapping or you use graphical mapping (even with user-defined function), then you have a java class. The problem is that XI 2.0 reloads this class during processing every message, so even if you load some data from your data source into your structures in the memory, this data will be lost after reloading your mapping class.
    Regards,
    Andrzej Filusz

  • How to call a java function that is in page header from a process in page.

    Hi,
    Generally we call plsql process from a javascript in the header of that page.
    But i want the other way around.
    Is it possible or is it a completely wrong idea.
    I am thinking so because we are able to call javascripts from items and buttons why cant we do so from a process.
    Thanks and Regards,

    943323 wrote:
    Hi,
    Generally we call plsql process from a javascript in the header of that page.
    But i want the other way around.
    Is it possible or is it a completely wrong idea.
    I am thinking so because we are able to call javascripts from items and buttons why cant we do so from a process.It's a "completely wrong idea". Processes and PL/SQL run in the database on the server. JavaScript runs in the browser on the client. For basuic security reasons the browser must make requests to the server, not the other way round.
    Please update your forum profile with a real handle instead of "943323".

  • What are the Built-In-Functions in XSLT mapping?

    what are the Built-In-Functions in XSLT mapping?

    hi praveen
    check the below blogs
    XSLT MAPPING                                   
    Step u2013 By u2013 Step Simple Approach for XSLT Mapping                                   
    Step – By – Step Simple Approach for XSLT Mapping                                   
    XSLT mapping for multiple segments of XML                                   
    XSLT mapping for multiple segments of XML                                   
    IF - ELSE IF and XSLT - A Better work around ?                                   
    IF - ELSE IF and XSLT - A Better work around ?                                   
    Calling instance (object) method of ABAP Class into xslt mapping by using SAP: CALL-EXTERNAL                                             
    Calling instance (object) method of ABAP Class into xslt mapping by using SAP: CALL-EXTERNAL                                             
    xpath functions in xslt mapping                                             
    xpath functions in xslt mapping                                             
    Using XSLT Mapping within the J2EE Adapter Framework                                             
    https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/3823 [original link is broken] [original link is broken] [original link is broken]                                             
    EDIFACT to XML - Stylus Studio Solution                                             
    EDIFACT to XML - Stylus Studio Solution                                             
    Running NetWeaver's XSLT processor from XMLSpy                                             
    Running NetWeaver's XSLT processor from XMLSpy                                             
    generic xslt mapping part 1                                             
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/01a57f0b-0501-0010-3ca9-d2ea3bb983c1                                             
    generic xslt mapping part 1          part2                                   
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/9692eb84-0601-0010-5ca0-923b4fb8674a                                             
    xslt recursive templates                                             
    XSLT: Recursive Templates                                             
    Generating Generic XML / HTML files without using XSLT Mappings                                                       
    Generating Generic XML / HTML files without using XSLT Mappings                                                       
    regards
    kummari

  • How to use standard java functions in a XSLT mapping

    Hi All,
    I wish to use a standard java function in a XSLT mapping, The issue is either i am giving incorrect namespace which is used to invoke the function or the signature of the function call is incorrect, I have read all the links in http://help.sap.com, and i know <b> one can enhance a XSLT mapping by writing one's own java code and thereby using java standard functions </b>, but the requirement is such that i need to try and use java standard function in XSLT mapping itself.
    Please refer to the sample code below:
    <?xml version="1.0" encoding="UTF-8"?>
      <xsl:stylesheet version="1.0"  
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:javamap="java:java.lang.String">
    <xsl:output method="text"/>
    <xsl:template match="/">
    <xsl:variable name="input" select="Title">
    <xsl:if test="function-available('javamap:toUpperCase')">
    <xsl:value-of select="javamap:toUpperCase($input)"/>
    </xsl:if>
    Author:<xsl:value-of select="Author"/>
    </xsl:template>
    </xsl:stylesheet>
    error encountered is: Illegal number or type of arguments.
    please reply if you have tried a similar scenario in SAP XI.
    Thanks & Regards,
    Varun

    Hi Varun,
        First of all i want to tell you that as per the documentation you can only call the static function inside xslt mapping. Your toUpperCase method is a non static function.
    What i am getting is that you have an element called Author and you want to convert its value into uppercase.
    you can write your own user defined function which is static.
    Signature of your java method :
    public static string toUpperCase(String Author,Map inputparam)
    try this xslt map.
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="2.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:javamap="java:JavaProgram">
         <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
         <xsl:param name="Author">
                 <xsl:value-of select="//Author_name"/>
         </xsl:param>
         <xsl:param name="inputparam" />
         <xsl:template match="/">
         <Author>
                 <xsl:if test="function-available('javamap:toUpperCase')">
                  <xsl:value-of select="javamap:toUpperCase($Author,$inputparam)"/>
                 </xsl:if>
         </Author>
         </xsl:template>
    </xsl:stylesheet>
    Hope this will work.
    Thanks and Regards
    Vishal Kumar

  • Calling Java class in XSLT mapping

    Hi,
    how can we call a java class in XSLT mapping..
    thanks
    guna

    This is a good one too:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/8e7daa90-0201-0010-9499-cd347ffbbf72
    Found this one helpfull too
    http://www.cafeconleche.org/books/xmljava/chapters/ch17s03.html
    Christof

  • How to call external files from java?

    How to call external files in java. For example how to call a *.pdf file to open in its default editor(say Acrobat), or a *.html file to open in the default browser or a *.txt file in a notepad etc..,
    In my program i have *.chm (Compiled Windows HTML Help) help file. how to open it in its default editor it?

    Jayarathina_Madharasan wrote:
    no one answered my questionHi what wrong did i do...basically insulted all the volunteers here who took the time to consider your question and try to offer you help. Other than that, you did nothing wrong.
    From JavaRanch :
    And even if an answer doesn't solve your problem, even if it should totally miss the point - the best thing to do to motivate others to continue trying to help you is showing respect and gratitude for the investment of time that was put into dealing with your issue.
    Edited by: Encephalopathic on Apr 14, 2008 10:01 AM

  • 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

  • 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.

  • I want to call External Java class from the PL/SQL

    Hi,
    I am using Oracle Apps R11i (11.5.7), I wanted to call external Java class from the PL/SQL. This external Java class is residing in another application server.
    How do I do this.
    I know one way. Develop C routine in Oracle Apps to call external java class and call this C routine from the PL/SQL.
    Is there any simple method available? or any other method?
    Thanks in advance.
    -Venkat

    First of all, this is a Java application you're talking about, right (i.e. it has a main() function)? It's not just a class that you're trying to instantiate is it? If it's an application, you obviously have to start a new virtual machine to run it (rather than using the virtual machine built into the database like stored java). I'm a little leary of your mention of an "application server" as this would more commonly mean that a virtual machine is already over there running with access to this class. In which case, you'd typically interface with SOAP or some other RPC API.
    All that aside, as long as you have physical disc access (through NFS or whatever) to the class file, you could use a java wrapper class with a system call to do this. In fact, there is a thread in just the last day or so on this very forum that has the code to do just that (see " Invoking OS Commands from PL/SQL"). However, it's worth noting that the virtual machine will be running on the database server in this case and not the application server.

  • 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

  • XSLT using Java function from graphical mapping (RFClookup)

    Hi,
    I was wondering if it is possible to use the standard Java functions of the graphical mapping (RFCLookup, Datetrans, ...) or from my own UDF inside an xslt mapping. Does anyone have every tried this or is an example available ?
    Regards Bernd

    Hi Bernd,
    here you can find an example how to use RFC lookup from an XSLT Mapping:
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/05a3d62e-0a01-0010-14bc-adc8efd4ee14?quicklink=index&overridelayout=true
    Is this what you're looking for?
    Regards,
    Gábor

  • 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;

Maybe you are looking for