Bodo,

The STAF colon-length-colon format is for an entire option value in a STAF 
service request (as talked about in the STAF User's Guide).

You need to understand Python to know what characters in a string like 
this need to be replaced.  This isn't really a STAF/STAX question, but 
more of a Python question on how to construct string literals.  Please 
read section "Using Python for Expression Evaluation" in the STAX User's 
Guide and you can google for more information on Python. 

For example, say you wanted to run the following command via a <process> 
element in a STAX job:

  myCommand -file: "C:\Program Files\myApp" -x: 'Hi' 

you could specify:

  <parms>"-file: \"C:\\Program Files\\myApp\" -x: 'Hi'"</parms>

or you could specify it as follows:

  <parms>'-file: "C:\\Program Files\\myApp" -x: \'Hi\''</parms>


 Python documentation provides complete information about how to construct 
string literals such as the following information:

"There are several different ways to construct string literals in Python. 
String literals can start and end with single quotes or double quotes.  In 
either case, the other kind of quote can be used safely inside the 
literal.  Within the quotation marks, special characaters are escaped 
using a backslash.  The list of escapes is based on C and is slightly 
different from Java's escape list.  Unlike Java, backslashes followed by 
characters not on the following list of escapes are legal in strings, and 
are treated merely as normal characters.

Backslash Escape Characters:

Escape character  Meaning 
----------------  -----------------------------------------
\\                Backslash (\)
\'                Single quote (')
\"                Double quote (")
\r                Carriage return
\t                Tab
\uxxxx            Unicode 16-bit character value xxxx (hex)
\a                Bell (ASCII character number 13)
\b                Backspace
\f                Formfeed
\n                Linefeed or newline
\N{name}          Unicode character identified by "name"
\Uxxxxxxxx        Unicode 32-bit characer xxxxxxxx (hex)
\v                Vertical tab character
\ooo              Unicode 8-bit character in octal
\xhh              hexadecimal

String literals may also begin and end with either three single or three 
double quotes.  A triple-quoted string may include newline characters 
(which would ordinarily need to be escaped) or individual quotation marks.

   """some
  long
  string"""

A string literal may also have an r or R before the inital quote, to 
indicate a "raw string".  Inside a raw string, backslash escape does not 
work and backslashes are treated as normal characters.  Quotation marks 
may be escaped in raw strings, but the backslash stays in the string.

  >>> r"c:\program files"
  'c:\\program files'

  >>> r"\""
  '\\"'

Notice that the raw string results in a normal string -- after the string 
is created, you can't tell whether itwas created using the raw option. Raw 
strings are just a flavor or string literal.   They are often used in 
regular expressions to keep them from looking even more like random 
noise."

So, in the future, you can look at Python documentation to get answers to 
questions on Python (instead of posting to the staf-users mailing list).


Note, you also need to be careful when specifying a < or & within a STAX 
xml file, or a { in a STAF service request option value that resolves 
variables:

- Also, note that XML processors assume that < always starts a tag and 
that & always starts an entity reference, so you should avoid using those 
characters for anything else. You must use the entity reference &lt; 
instead of < and entity reference &amp; instead of & or else you'll get an 
XML parsing error.
- Also, note that STAF automatically resolves STAF variables in a PROCESS 
START COMMAND and PARMS option, so if you need to specify a {, you need to 
escape it with a caret, e.g. ^{

--------------------------------------------------------------
Sharon Lucas
IBM Austin,   luc...@us.ibm.com
(512) 286-7313 or Tieline 363-7313




Strösser, Bodo <bodo.stroes...@ts.fujitsu.com> 
07/10/2009 03:10 PM

To
"'staf-users@lists.sourceforge.net'" <staf-users@lists.sourceforge.net>
cc

Subject
[staf-users] STAX: How to format <parms> element content






Hi,
 
when starting a <process> in STAX, parameters for the process must be
specified in the <parms> element.
 
I need to handle the case of a number of strings containing one parameter 
each.
The strings might contain characters like Quotation marks, Single quotes 
or
Backslashes. How would I need to prepare the python string for the <parms>
element, so that the parameters are transfered to the process 
transparently?
The colon-length-colon method seems not to work here.
 
Best regards
Bodo
 
 
------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge 
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full 
prize 
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge
_______________________________________________
staf-users mailing list
staf-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/staf-users

Reply via email to