From: David B. <bd...@us...> - 2006-08-24 14:52:58
|
Yes, there are many different ways to do this. Here is a sample STAX job that demonstrates some of them: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE stax SYSTEM "stax.dtd"> <stax> <defaultcall function="test"></defaultcall> <script> myFirstName = 'John' myLastName = 'Doe' </script> <function name="test"> <function-map-args> <function-arg-def name="firstName" type="optional" default="myFirstName"> </function-arg-def> <function-arg-def name="lastName" type="optional" default="myLastName"> </function-arg-def> </function-map-args> <sequence> <message log="1">'Hello %s %s!' % (firstName, lastName)</message> <return>'Hello %s %s!' % (firstName, lastName)</return> </sequence> </function> </stax> The "test" function accepts two optional arguments, and uses the default values that are set in the <script> element which is executed prior to the function being called. So, if you run this from the command line: $ STAF local STAX EXECUTE FILE c:/staxtest/func.xml WAIT RETURNRESULT Response -------- Job ID: 16 Result: Hello John Doe! You can override the values in the <script> by specifying the SCRIPT option: $ STAF local STAX EXECUTE FILE c:/staxtest/func.xml WAIT RETURNRESULT SCRIPT "myFirstName = 'Jane'; myLastName = 'Smith'" Response -------- Job ID: 17 Result: Hello Jane Smith! You can also override the values in the <script> by specifying the SCRIPTFILE option: $ cat c:/temp/myName.py myFirstName = 'Mark' myLastName = 'Fisher' $ STAF local STAX EXECUTE FILE c:/staxtest/func.xml WAIT RETURNRESULT SCRIPTFILE c:/temp/myName.py Response -------- Job ID: 18 Result: Hello Mark Fisher! You can also pass the arguments to the function: $ STAF local STAX EXECUTE FILE c:/staxtest/func.xml WAIT RETURNRESULT ARGS "{ 'firstName' : 'Tom', 'lastName' : 'Smith' }" Response -------- Job ID: 19 Result: Hello Tom Smith! Post again if you have more specific questions. David Bender STAF/STAX Development 8-1268 (512-838-1268) IBM Austin Bldg. 903-5B002 Internet: bd...@us... "m.p.sairam" <ms...@in...> Sent by: sta...@li... 08/24/2006 07:47 AM To staf <sta...@li...> cc Subject [staf-users] help hi, Can I pass the functional arguments during the run time of the xml file where the arguments required by xml will be generated by the python script before the actual function starts its execution? ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ staf-users mailing list sta...@li... https://lists.sourceforge.net/lists/listinfo/staf-users |