Author |
Message
|
jjordan |
Posted: Fri Oct 14, 2005 2:13 am Post subject: Converting A Node of an XML Tree to A BLOB |
|
|
Novice
Joined: 14 Oct 2005 Posts: 17 Location: Portland, ME
|
This is needed to send an attachment using the SendMail plugin.
Using an input message similar to the following in an XML domain:
<SENDMAILMSG><FROM>a</FROM><TO>b</TO><THEATTACHMENT><![CDATA[binary character data representing a .pdf file]]</THEATTACHMENT></SENDMAILMSG>
I need to put <THEATTACHMENT> into OutputRoot.BLOB.BLOB for it to appear as an attachment. Using BITSTREAM, it put the whole message (<SENDMAILMSG>) into the attachment.
How do I convert the single node to a BLOB and put it in the OutputRoot.BLOB.BLOB node. I haven't had any luck with ASBITSTREAM but I may be specifying the parameters incorrectly.
Thanks,
Jeff |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Oct 14, 2005 3:13 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
BITSTREAM is deprecated.
Don't use it.
Please describe EXACTLY what the output of ASBITSTREAM looks like, and why it is a problem. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
jjordan |
Posted: Fri Oct 14, 2005 6:05 am Post subject: |
|
|
Novice
Joined: 14 Oct 2005 Posts: 17 Location: Portland, ME
|
Actually, I'm having trouble coding it at all.
set OutputRoot.BLOB.BLOB = ASBITSTREAM(InputRoot.XML.SENDMAILMSG.THEATTACH OPTIONS RootBitStream);
Right now it errors on the flow - "No valid body of the document could be found" - which makes sense if its expecting it to be an XML format. |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Oct 14, 2005 6:08 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
RootBitStream means "the entire message tree".
Try FolderBitStream. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
jjordan |
Posted: Fri Oct 14, 2005 10:41 am Post subject: |
|
|
Novice
Joined: 14 Oct 2005 Posts: 17 Location: Portland, ME
|
FolderBitStream worked much better EXCEPT it includes the tags and the content.
Ultimately, I want the content of the one node converted to a BLOB (i.e. the content of the XML node converted to a stream of bytes representing the hex version of each and every byte in the XML content stream. How do I get to that content (including the removal of the <CDATA> tags to produce a binary stream able to be put in Output.BLOB.BLOB. |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Oct 14, 2005 10:44 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
So you don't actually want a bit stream of a SUBSECTION of the tree.
You want a bitstream of the VALUE of an ELEMENT.
And
Code: |
CAST(InputRoot.XML.SENDMAILMSG.THEATTACH as BLOB CCSID InputRoot.Properties.CodedCharSetID); |
doesn't work? _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
jjordan |
Posted: Mon Oct 17, 2005 8:32 am Post subject: |
|
|
Novice
Joined: 14 Oct 2005 Posts: 17 Location: Portland, ME
|
This does not work. I get the following exception message:
String is not of correct form for byte array. Must consist of only 0..9,a..f,A..F
which makes sense, because it appears to be expecting a hex rendition of a string. What I want is to be able to take a tag in the input message:
<Message><SomeTag>This is text</SomeTag></Message>
and set OutputRoot.BLOB.BLOB = (some conversion of) InputRoot.XML.Message.SomeTag
and have it interpreted as (0x)546869732069732074657874 (hex equivalent of "This is text". Ultimately, I want to have .SomeTag contain a "text" stream of a .pdf file, that I can then insert as is into the .BLOB field.
Thanks for your help - its so much closer. There's just this small gap I still need to bridge.
Jeff |
|
Back to top |
|
 |
renevanduren |
Posted: Thu Oct 20, 2005 4:19 am Post subject: Same problem |
|
|
Newbie
Joined: 20 Oct 2005 Posts: 1
|
I have te same question/problem. If you have a solution....i would really like to know because i can't find it elsewhere
Thanx in advance |
|
Back to top |
|
 |
kimbert |
Posted: Wed Oct 26, 2005 1:04 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
jjordan, renevanduren,
Is the content of the field encoded as
a) base64 or
b) hexBinary
If a), you must define a message set and use the MRM domain - it will automatically decode the base64 data into a BLOB in the tree.
If b), Jeff's solution should work - but maybe the CDATA[[ stuff needs to be removed before the CAST is performed? |
|
Back to top |
|
 |
jjordan |
Posted: Wed Oct 26, 2005 5:02 am Post subject: |
|
|
Novice
Joined: 14 Oct 2005 Posts: 17 Location: Portland, ME
|
kimbert wrote: |
jjordan, renevanduren,
Is the content of the field encoded as
a) base64 or
b) hexBinary
If a), you must define a message set and use the MRM domain - it will automatically decode the base64 data into a BLOB in the tree.
If b), Jeff's solution should work - but maybe the CDATA[[ stuff needs to be removed before the CAST is performed? |
Actually, its not "encoded" (although I honestly don't know what the Base64 encoding is all about) - its just a stream of bytes (each with any value between 0 and 255). It needs to be converted to a bitstream first, which can then be stored as a blob:
1) convert "This is text" to (0x) 546869732069732074657874
2) set OutputRoot.BLOB.BLOB = cast(x'546869732069732074657874' as blob);
3) "This is text" is a simple example. It could actually contain ANYTHING.
Using ASBITSTREAM, you get the tags included, which you don't want. I'm not sure why they didn't provide a means to do the same thing for the contents only of an XML field.
Thanks!
Jeff |
|
Back to top |
|
 |
JT |
Posted: Wed Oct 26, 2005 5:25 am Post subject: |
|
|
Padawan
Joined: 27 Mar 2003 Posts: 1564 Location: Hartford, CT.
|
The CAST to the BLOB format should work. I believe your having the same problem as another recent poster.
Instead of this:
Quote: |
CAST(InputRoot.XML.SENDMAILMSG.THEATTACH as BLOB CCSID InputRoot.Properties.CodedCharSetID); |
Do this:
Quote: |
CAST(InputRoot.XML.SENDMAILMSG.THEATTACH as BLOB CCSID InputRoot.Properties.CodedCharSetId); |
By the way, is the XML element THEATTACH or THEATTACHMENT ? |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Oct 26, 2005 5:27 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
JT wrote: |
I believe your having the same problem as another recent poster. |
Which was also the result of me forgetting how to spell CodedCharSetId...
 _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
jjordan |
Posted: Wed Oct 26, 2005 8:44 am Post subject: |
|
|
Novice
Joined: 14 Oct 2005 Posts: 17 Location: Portland, ME
|
It does work! Thanks for your help!
Once I fixed it, it worked in most, but not all situations. My problem lies in that some of the characters don't "cast well", and causes nothing to be assigned to the BLOB (i.e. 0x14 (^T - tab) doesn't). Since the attachment could be a .pdf in a <![CDATA[]]>, the data is "unpredictable".
This leads to a follow up, then, of how do I message a .pdf as part of a stream and cast it to a BLOB?
You're being very helpful! I appreciate it!
Jeff |
|
Back to top |
|
 |
jefflowrey |
Posted: Wed Oct 26, 2005 9:12 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
You won't be able to fully attach all possible PDFs in a <![CDATA[]]> tag set.
For example
Code: |
<body><![CDATA[<body>]]/> </body> |
is not valid XML. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
jjordan |
Posted: Wed Oct 26, 2005 9:23 am Post subject: |
|
|
Novice
Joined: 14 Oct 2005 Posts: 17 Location: Portland, ME
|
Exactly! I think I need to persue a different strategy in terms of passing the attachments (such as converting them to a hex string format BEFORE submitting the message).
Along that lines and before I start, is anybody aware of size limitations (other than the size of the message itself) for casting data?
This whole topic has been very educational, and I've learned a lot that I wasn't familiar with until now!
Thanks,
Jeff |
|
Back to top |
|
 |
|