Author |
Message
|
lium |
Posted: Thu Jul 08, 2010 6:15 am Post subject: How to generate line feed and cartridge for a string |
|
|
Disciple
Joined: 17 Jul 2002 Posts: 184
|
I would like to output a XML element which includes 0x0a0d(line feed, cartridge). Let me say :
DECLARE firstName CHAR 'David';
DECLARE lastName CHAR 'Bond';
SET OutputRoot.XMLNSC.Result.Name = firstNmae || lastName;
I would like Name includes 0x0a0d between first name and last name.
How can I do to obtain that?
Thanks, |
|
Back to top |
|
 |
lancelotlinc |
Posted: Thu Jul 08, 2010 7:36 am Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
First take the sellophane wrap off of the cartridge.
Then try this code:
Code: |
DECLARE firstName CHAR 'James';
DECLARE lastName CHAR 'Bond';
DECLARE title CHAR 'double oh seven';
DECLARE CR CHAR CAST(CAST('X''0D''' AS BLOB) AS CHAR CCSID ...);
DECLARE LF CHAR CAST(CAST('X''0A''' AS BLOB) AS CHAR CCSID ...);
SET OutputRoot.XMLNSC.Result.Name = firstNmae || lastName || title || CR || LF;
|
Ciao' _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
lium |
Posted: Thu Jul 08, 2010 9:54 am Post subject: |
|
|
Disciple
Joined: 17 Jul 2002 Posts: 184
|
Really appreciate.
I tested and it worked! |
|
Back to top |
|
 |
kimbert |
Posted: Thu Jul 08, 2010 11:20 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
I would not bother putting in the carriage return ( or the cartriidge, if you prefer ). Any proper XML parser will throw it away, so the application that reads your XML will only ever see a single line feed (0x0A ). |
|
Back to top |
|
 |
lium |
Posted: Thu Jul 08, 2010 11:25 am Post subject: |
|
|
Disciple
Joined: 17 Jul 2002 Posts: 184
|
Tx for reply Kimbert.
The data is to be used by pdf generator.
The reason I put it worked was because I saw 2 lines in the output pdf. |
|
Back to top |
|
 |
mgk |
Posted: Thu Jul 08, 2010 12:20 pm Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
Not a big problem, but this code is a little inefficient:
Code: |
DECLARE CR CHAR CAST(CAST('X''0D''' AS BLOB) AS CHAR CCSID ...); |
As the original data could just be a BLOB literal, there is no need to CAST it to BLOB, so the better code would be:
Code: |
DECLARE CR CHAR CAST( X'0D' AS CHAR CCSID ...); |
Once we have done this we quickly realise that if we are always adding a CR and an LF together we may as well do it in one step like this:
Code: |
DECLARE CRLF CHAR CAST( X'0D0A' AS CHAR CCSID ...); |
And use it like this:
Code: |
SET OutputRoot.XMLNSC.Result.Name = firstNmae || CRLF || lastName; |
Kind Regards, _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
Back to top |
|
 |
lancelotlinc |
Posted: Thu Jul 08, 2010 12:23 pm Post subject: |
|
|
 Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
Yes much more efficient. But you forgot the title. Mr. Bond would not be pleased. Everyone calls him by his title.
Code: |
DECLARE title CHAR 'double oh seven';
SET OutputRoot.XMLNSC.Result.Name = firstName || lastName || title || CRLF;
|
_________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Jul 08, 2010 12:59 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
lancelotlinc wrote: |
Yes much more efficient. But you forgot the title. Mr. Bond would not be pleased. Everyone calls him by his title.
Code: |
DECLARE title CHAR 'double oh seven';
SET OutputRoot.XMLNSC.Result.Name = firstName || lastName || title || CRLF;
|
|
Then shouldn't it be
Code: |
Set OutputRoot.XMLNSC.Result.name = lastName||', '||firstName||lastName||title||CRLF; |
|
|
Back to top |
|
 |
kimbert |
Posted: Thu Jul 08, 2010 3:16 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
The data is to be used by pdf generator.
The reason I put it worked was because I saw 2 lines in the output pdf. |
Yes - and the output of XMLNSC probably contains the CRLF. But if the pdf generator uses a real XML parser, only the linefeed will get past it. |
|
Back to top |
|
 |
|