Using Python's import statement within a <script> element imports Python
modules and/of Java classes. Python itself knows nothing about STAX and
STAX functions. Specifying
<script>from com.ibm.staf import STAFUtil</script>
imports the Java STAFUtil class from package com.ibm.staf. This has
nothing to do with importing function STAXUtilImportSTAFVars from the
STAXUtil.xml file.
You must use the STAX <import> element to import functions for a STAX xml
file. The "STAXUtilImportSTAFVars" function is provided in the
stax/libraries/STAXUtil.xml file (which will be located in the directory
where you extracted/unzipped the STAXVxxx.tar/zip file (e.g.
C:\STAF\services\stax\libraries\STAXUtil.xml). Please see section
"import: Import Functions From Another STAX XML Job File" at
http://staf.sourceforge.net/current/STAX/staxug.html#Header_Import for
detailed information on how to use the <import> element and examples --
even an example of importing STAX functions from the STAXUtil.xml file.
For example:
<stax>
<defaultcall function="main"/>
<script>
# ImportMachine should be set to the machine where STAXUtil.xml
resides
# (e.g. 'local' if the file resides on the STAX service machine).
# ImportDirectory should be set to the directory which contains
STAXUtil.xml.
ImportMachine = 'local'
ImportDirectory = 'C:/STAF/services/stax/libraries'
ImportFile = '%s/STAXUtil.xml' % (ImportDirectory)
</script>
<function name="main">
<sequence>
<import machine="ImportMachine" file="ImportFile"/>
<call function="'STAXUtilImportSTAFVars'">
[
{'STAF/Config/OS/Name': 'osName', 'STAF/Version':
'mySTAFVersion'},
'client1.company.com'
]
</call>
<script>[rc, errorList] = STAXResult</script>
<call function="'STAXUtilCheckSuccess'">
{ 'result': rc == 0,
'failMsg': 'STAXUtilImportSTAFVars failed. RC=%s ErrorList=%s'
% \
(rc, errorList),
'sendToMonitor': 1, 'recordStatus': 0 }
</call>
<!-- Do whatever -->
</sequence>
</function>
</stax>
See http://staf.sourceforge.net/current/STAXLibraries/index.html for more
information on the STAX functions provided in the STAXUtil.xml file.
--------------------------------------------------------------
Sharon Lucas
IBM Austin, [EMAIL PROTECTED]
(512) 838-8347 or Tieline 678-8347
"Devvan Stokes" <[EMAIL PROTECTED]>
Sent by: [EMAIL PROTECTED]
09/18/2008 04:52 PM
To
<staf-users@lists.sourceforge.net>
cc
Subject
[staf-users] correct usageof imported functions
I'm attempting import and call functions from com.ibm.staf, specifically
'STAXUtilImportSTAFVars'.
This is how I'm attempting the import:
<script>from com.ibm.staf import STAFUtil</script>
I believe this is working because if I change the library name to
something that doesn't exist, execution of my STAX job terminates with an
error pointing to that name. The following fails, though:
<call function="'STAXUtilImportSTAFVars'">
[
{'some remote variable': 'local variable name'},
'remote machine name'
]
</call>
STAXUtilImportSTAFVarsv doesn't exist, according to the error. Is there
anything obviously wrong there? Are there some rules about qualifying the
function name?
If I understand correctly, there is another way of importing with STAX,
and that's with the <import> tags. If I wanted to attempt this same thing
by importing xml functions, is it correct that the same operation could be
done using the library here (
http://staf.sourceforge.net/current/STAXLibraries/libraries/package-overview.html
)?
Thank you.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's
challenge
Build the coolest Linux based applications with Moblin SDK & win great
prizes
Grand prize is a trip for two to an Open Source event anywhere in the
world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users