10 Replies Latest reply: Jul 23, 2013 10:42 AM by KeithFosberg RSS

    User Defined Functions in Mapper

    KeithFosberg

      I have user defined functions that work in BPEL but I am unable to get them to work in Mapper. They appear where expected in jDeveloper but throw "function not found" runtime errors.

       

      Can someone look at my config files and see if the error pops out? Thanks bunches!

       

      bpel file:

      <soa-xpath-functions xmlns="http://xmlns.oracle.com/soa/config/xpath"

                      xmlns:f17="http://entp.hud.gov/customxpath/functions"

                      version="11.1.1"

                      resourceBundle="oracle.tip.tools.ide.common.resource.IDEMessageBundle"

                      >

        <function name="f17:editCaseNumber">

        <className>com.f17.customfunction.editCaseNumber</className>

        <return type="tree"/>

        <params>

        <param name="stringToFormat" type="string"/>

        <param name="command" type="string"/>

        </params>

        <desc>Validates and formats case numbers</desc>

        <detail>

                      <![CDATA[This is a custom function. If you use it you must include the

        following namespace declaration in your BPEL file.

        <br /><br />

        xmlns:f17="http://entp.hud.gov/customxpath/functions"

        <br /><br />

        USE: f17:editCaseNumber(string,string)<br />

                      String 1 is the data<br />

                      String 2 is the command. Valid commands are:<br />

                      1 = Verify check digit and return as nnnnnnnnnn<br />

                      2 = Verify check digit and return as nnn-nnnnnnn<br />

                      3 = Append check digit and return as nnnnnnnnnn<br />

                      4 = Append check digit and return as nnn-nnnnnnn

                      <br /><br />

                      Returns XML document fragment:<br />

                      Import f17userDefinedFusnctions.xsd to prototype variable space.<br />

                      See documentation for details.]]>

                  </detail>

        </function>

        <function name="f17:compressFile">

        <className>com.f17.customfunction.compressFile</className>

        <return type="tree"/>

        <params>

        <param name="stringToFormat" type="string"/>

        </params>

        <desc>Compresses large strings for DB storage</desc>

        <detail>

                      <![CDATA[This is a custom function. If you use it you must include the

        following namespace declaration in your BPEL file.

        <br /><br />

        xmlns:f17="http://entp.hud.gov/customxpath/functions"

        <br /><br />

        USE: f17:compresFile(string)

                      <br /><br />

                      Returns XML document fragment:<br />

                      See documentation for details.]]>

                  </detail>

        </function>

        <function name="f17:sortList">

        <className>com.f17.customfunction.sortList</className>

        <return type="tree"/>

        <params>

        <param name="listIn" type="string"/>

        </params>

        <desc>Sorts lists</desc>

        <detail>

                      <![CDATA[This is a custom function. If you use it you must include the

        following namespace declaration in your BPEL file.

        <br /><br />

        xmlns:f17="http://entp.hud.gov/customxpath/functions"

        <br /><br />

        USE: f17:sortList(String)<br />

                      Build string as: &lt;list&gt;&lt;item&gt;[data]&lt;/item&gt;...&lt;/list&gt;<br />

                      Returns XML document fragment:<br/>

                      Import f17userDefinedFusnctions.xsd to prototype variable space.<br />

                      See documentation for details.]]>

                  </detail>

        </function>

        <function name="f17:replaceString">

        <className>com.f17.customfunction.replaceString</className>

        <return type="string"/>

        <params>

        <param name="StringToFix" type="string"/>

        <param name="RegX" type="string"/>

        <param name="replaceString" type="string"/>

        <param name="mode" type="string"/>

        </params>

        <desc>Exposes replaceFirst and replaceAll java functions</desc>

        <detail>

                      <![CDATA[This is a custom function. If you use it you must include the

        following namespace declaration in your BPEL file.

        <br /><br />

        xmlns:f17="http://entp.hud.gov/customxpath/functions"

        <br /><br />

        USE: f17:replaceString(String,String,String,String)<br />

                      String to edit, regular expression, replacement string [optional] mode -- 1= all, 2 = first defaults to all<br />

                      See documentation for details.]]>

                  </detail>

        </function>

      </soa-xpath-functions>

       

       

      mapper file:

       

      <soa-xpath-functions

              xmlns="http://xmlns.oracle.com/soa/config/xpath"

              xmlns:repl="http://www.oracle.com/XSL/Transform/java/com.f17.customfunction.replaceString"

              xmlns:comp="http://www.oracle.com/XSL/Transform/java/com.f17.customfunction.compressFile"

              version="11.1.1"

              resourceBundle="oracle.tip.tools.ide.common.resource.IDEMessageBundle"

              >

        <function name="comp:compressFile">

        <className>com.f17.customfunction.compressFile</className>

        <return type="tree"/>

        <params>

        <param name="stringToFormat" type="string"/>

        </params>

        <desc>Compresses large strings for DB storage</desc>

        <detail>

                      <![CDATA[This is a custom function. If you use it you must include the

        following namespace declaration in your BPEL file.

        <br /><br />

        xmlns:f17="http://entp.hud.gov/customxpath/functions"

        <br /><br />

        USE: f17:compresFile(string)

                      <br /><br />

                      Returns XML document fragment:<br />

                      See documentation for details.]]>

                  </detail>

        </function>

        <function name="repl:replaceString">

        <className>com.f17.customfunction.replaceString</className>

        <return type="string"/>

        <params>

        <param name="StringToFix" type="string"/>

        <param name="RegX" type="string"/>

        <param name="replaceString" type="string"/>

        <param name="mode" type="string"/>

        </params>

        <desc>Exposes replaceFirst and replaceAll java functions</desc>

        <detail>

                      <![CDATA[This is a custom function. If you use it you must include the

        following namespace declaration in your BPEL file.

        <br /><br />

        xmlns:f17="http://entp.hud.gov/customxpath/functions"

        <br /><br />

        USE: f17:replaceString(String,String,String,String)<br />

                      String to edit, regular expression, replacement string [optional] mode -- 1= all, 2 = first defaults to all<br />

                      See documentation for details.]]>

                  </detail>

        </function>

      </soa-xpath-functions>

        • 1. Re: User Defined Functions in Mapper
          KeithFosberg

          I was hoping someone would be familiar with this.

          • 2. Re: User Defined Functions in Mapper
            643881

            Hi,

             

            If you want to use custom xpath functions in xsl.. the name space for the functions should start with

             

            http://www.oracle.com/XSL/Transform/java/<package.ClassName>

             

            Thanks,

            Jp

            • 3. Re: User Defined Functions in Mapper
              KeithFosberg

              If you look up above... they do.

              • 4. Re: User Defined Functions in Mapper
                Karan Mann

                May be your custom function jar is not properly deployed..Can you cross check that.

                 

                Regards,

                Karan

                Oracle Fusion Middleware Blog

                • 5. Re: User Defined Functions in Mapper
                  643881

                  the name of the mapper file should be ext-soa-xpath-functions-config.xml for xslt functions.

                  for bpel functions, the name of the mapper file should be ext-bpel-xpath-functions-config.xml

                  -Thanks,

                  Jp

                  • 6. Re: User Defined Functions in Mapper
                    KeithFosberg

                    All of the functions work in BPEL. It is only in Mapper (xsl) that they do not. Unless I need to deploy the jar in more than one place I don't think it can be a problem with its deployment.

                    • 7. Re: User Defined Functions in Mapper
                      KeithFosberg
                      META-INF/MANIFEST.MFFri Jul 22 21:46:54 EST 1132527
                      META-INF/ext-bpel-xpath-functions-config.xmlSat Jul 09 09:48:48 EST 11339773977
                      META-INF/ext-mapper-xpath-functions-config.xmlFri Jul 15 09:10:36 EST 11320372037
                      com/f17/customfunction/codeTyper.classSun Jul 03 08:50:48 EST 11315111511
                      com/f17/customfunction/compressFile.classSun Jul 03 08:57:04 EST 11323292329
                      com/f17/customfunction/deZipIt.classSat Jun 25 11:38:28 EST 11318751875
                      com/f17/customfunction/editCaseNumber.classSat Jun 25 11:51:16 EST 11337273727
                      com/f17/customfunction/functionTester.classTue Jul 05 13:05:10 EST 11312901290
                      com/f17/customfunction/getFormattedCaseNumber.classSat Jun 25 11:51:16 EST 11337143714
                      com/f17/customfunction/replaceString.classTue Jul 05 13:05:10 EST 11319571957
                      com/f17/customfunction/sortList.classTue Jun 28 11:13:12 EST 11357635763
                      com/f17/customfunction/zipIt.classSat Jun 25 11:38:28 EST 11311811181

                       

                      According to this site:

                      https://blogs.oracle.com/bwb/entry/creating_custom_xpath_functions_using

                       

                      The XSL functions should be in ext-mapper-xpath-functions-config.xml

                       

                      I'll try this in the morning. There is so much misinformation and the Oracle documentation is so bad that dealing with this stuff is 8% programming and 92% guessing.

                      • 8. Re: User Defined Functions in Mapper
                        Karan Mann

                        As a best practice, follow these conventions for creating functions:

                        • If possible, write functions that can be shared across all components. Functions shared by all components can be created in a configuration file named ext-soa-xpath-functions-config.xml. Note that you must implement XSLT Mapper functions differently than functions for Oracle BPEL Process Manager, Oracle Mediator, and human workflow.

                          For more information about description of these implementation differences, see Section B.7.1, "How to Implement User-Defined XPath Extension Functions".

                        • If you create a function for one component that cannot be used by others (for example, a function for Oracle BPEL Process Manager that cannot be used by Oracle Mediator or human workflow), then create that function in the configuration file specific to that component. For this example, the Oracle BPEL Process Manager function must be created in a configuration file named ext-bpel-xpath-functions-config.xml.

                         

                        For your reference: XPath Extension Functions  

                        Go through section B.7 Creating User-Defined XPath Extension Functions


                        Try using ext-soa-xpath-functions-config.xml configuration file.Hope this helps.

                         

                        Regards,

                        Karan

                        Oracle Fusion Middleware Blog

                        • 9. Re: User Defined Functions in Mapper
                          KeithFosberg

                          Thanks for the link. It appears that you cannot use IXPpath classes for Mapper. That's OK; I should be able to quickly redo some of these.
                          This looks like the correct solution.

                          • 10. Re: User Defined Functions in Mapper
                            KeithFosberg

                            None of the responses were *exactly* correct but they gave me enough information to solve the issue.

                            To implement this I have to code the functions slightly differently.

                            • The BPEL functions are all IXpathFunction extension classes.
                            • The Mapper functions are not.
                            • The BPEL functions are each distinct classes.
                            • The Mapper functions are a single class with a method for each desired function.
                            • The BPEL classes are exposed in the config file ext-bpel-xpath-functions-config.xml
                            • The Mapper class is exposed in the config file ext-mapper-xpath-functions-config.xml

                             

                            A BPEL class looks like:

                            public class editCaseNumber implements IXPathFunction {
                                public Object call(IXPathContext context, List args) throws XPathFunctionException {
                                   return docOut;
                                }
                            }
                            
                            

                             

                            A Mapper class looks like:

                            public class mapperFunctions {
                                public static String replaceString(String sIn,String sMat,String sRep,String mode){
                                    return finalString;
                                }
                                public static XMLDocumentFragment compressFile(String indoc){
                                    return docOut;
                                }
                            }
                            
                            

                            (I removed the code from these to  avoid confusion.)


                            My ext-mapper-xpath-functions-config.xml file looks like:

                            soa-xpath-functions
                                    xmlns="http://xmlns.oracle.com/soa/config/xpath"
                                    xmlns:map="http://www.oracle.com/XSL/Transform/java/com.f17.customfunction.mapperFunctions"
                                    version="11.1.1"
                                    resourceBundle="oracle.tip.tools.ide.common.resource.IDEMessageBundle"
                                    >
                              <function name="map:compressFile">
                              <className>com.f17.customfunction.mapperFunctions.compressFile</className>
                              <return type="tree"/>
                              <params>
                              <param name="stringToFormat" type="string"/>
                              </params>
                              <desc>Compresses large strings for DB storage</desc>
                              <detail>
                                            <![CDATA[This is a custom function for Mapper.
                              <br /><br />
                              USE: map:compresFile(string)
                                            <br /><br />
                                            Returns XML document fragment containing HEX binary string:<br />
                                            &lt;compressedFile$gt;[outPut]&lt;/compressedFile&gt;
                                            See documentation for details.]]>
                                        </detail>
                              </function>
                              <function name="map:replaceString">
                              <className>com.f17.customfunction.mapperFunctions.replaceString</className>
                              <return type="string"/>
                              <params>
                              <param name="StringToFix" type="string"/>
                              <param name="RegX" type="string"/>
                              <param name="replaceString" type="string"/>
                              <param name="mode" type="string"/>
                              </params>
                              <desc>Exposes replaceFirst and replaceAll java functions</desc>
                              <detail>
                                            <![CDATA[This is a custom function for Mapper.
                              <br /><br />
                              USE: map:replaceString(String,String,String,String)<br />
                                            String to edit,<br />
                                            regular expression,<br />
                                            replacement string mode<br />
                                            1 = all<br />
                                            2 = first occurance<br />
                                            See documentation for details.]]>
                                        </detail>
                              </function>
                            </soa-xpath-functions>