Author |
Message
|
firoj.badsa |
Posted: Wed Oct 31, 2012 12:16 pm Post subject: XML in email body |
|
|
 Centurion
Joined: 16 Feb 2007 Posts: 104
|
Hi,
I want to paste my input message into email body (and in actual xml structure). I was doing the below but its not posting the actual xml.. but something like .. X ''
DECLARE options INTEGER FolderBitStream;
DECLARE myString CHARACTER ASBITSTREAM(Environment.emailData OPTIONS options);
SET OutputRoot.BLOB.BLOB = CAST(myString AS BLOB CCSID 1208);
any quick help pls. |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Oct 31, 2012 12:22 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
You have a number of concepts that you don't understand.
First is that ASBITSTREAM returns a blob. So casting it to a BLOB doesn't help.
Second is that you haven't shown that Enviroment.emailData has an XML parser associated with it.
Third, there's no particular reason to use OutputRoot.BLOB.BLOB when passing data to an EmailOutput node. You can simply pass OutputRoot.XMLNSC. |
|
Back to top |
|
 |
firoj.badsa |
Posted: Wed Oct 31, 2012 12:32 pm Post subject: |
|
|
 Centurion
Joined: 16 Feb 2007 Posts: 104
|
Dear jeff,
thanks for your quick reply. I was able to paste the xml in the mail using OutputRoot.XMLNSC, but I am losing the tree structure. Any tips on this to keep the xml tree structure in the mail? |
|
Back to top |
|
 |
kimbert |
Posted: Wed Oct 31, 2012 1:10 pm Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Do you mean that you are losing the white space that makes the XML look 'pretty'? You *can* ask the XMLNSC parser to retain it, but there is usually no point. |
|
Back to top |
|
 |
firoj.badsa |
Posted: Wed Oct 31, 2012 11:21 pm Post subject: |
|
|
 Centurion
Joined: 16 Feb 2007 Posts: 104
|
Yes, I wanted to paste the xml with 'pretty' structure. How can I use the xmlnsc parser to retain this? thanks for your help. |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Nov 01, 2012 1:25 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
You need to instruct the XMLNSC parser to 'retain mixed content'.
And then reexamine your desire to use XML as a user displayable document, when it's intended to be machine consumable. |
|
Back to top |
|
 |
firoj.badsa |
Posted: Thu Nov 01, 2012 5:59 am Post subject: |
|
|
 Centurion
Joined: 16 Feb 2007 Posts: 104
|
I have tried to use this 'retain mixed content' properties of RCD node. seems no use. I doubt if this is at all possible within WMB to paste the preety xml format in email body. |
|
Back to top |
|
 |
kimbert |
Posted: Thu Nov 01, 2012 6:11 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
'Retain mixed content' is tested, and known to work. That does not mean that you are using it for the purpose that it was intended for. If you really need this 'pretty printing' then you will need to start diagnosing the problem in detail. And if you want more help, you will need to provide a lot more detail about the symptoms that you are observing. |
|
Back to top |
|
 |
firoj.badsa |
Posted: Thu Nov 01, 2012 6:19 am Post subject: |
|
|
 Centurion
Joined: 16 Feb 2007 Posts: 104
|
Ok. I should have mentioned that its not working in my case .
I had to print the xml in pretty format like ..
<ROOT>
<CHILD>1234</CHILD>
</ROOT>
but i am getting this in a single line in the email mail body. like ..
<ROOT><CHILD>1234</CHILD></ROOT> |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Nov 01, 2012 6:27 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Retain mixed content will only preserve the whitespace if the whitespace is there.
Because that's all it does - *preserve* any *existing* whitespace.
Again, you should be strongly concerned that someone is asking you to make a data format that is only intended to be consumed by machines (i.e. XML) into something that is "readable by a person".
And then you can consider serializing the message into a BLOB string, as you started out, and then doing something to add a CR/LF after every '>' character you find in the document.
That will at least get you
<ROOT>
<CHILD>
1234</CHILD>
</ROOT>
Your other choice is to recursively step through all of the children of XMLNSC and add mixed content that contains a CR/LF.
All of these are bad ideas.
Use DFDL (or mrm if you have to) to create a human readable format that matches the same XML data, and then send that to the EmailOutput node. |
|
Back to top |
|
 |
Vitor |
Posted: Thu Nov 01, 2012 6:42 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
mqjeff wrote: |
Again, you should be strongly concerned that someone is asking you to make a data format that is only intended to be consumed by machines (i.e. XML) into something that is "readable by a person". |
What does the receipient do with this text? If it's of any size, what use is it to them and are they using XMLSpy or similar to traverse it to obtain data? If so, tell them to use Edit -> Pretty Print XML and suck it up. Even if they're using some other XPath tool, it doesn't need to be formatted. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mqsiuser |
Posted: Fri Nov 02, 2012 11:00 pm Post subject: |
|
|
 Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
Even though XML is machine readable this "embed xml (in an email) in a human readable way (pretty print)" is a really valid requirement.
firoj.badsa wrote: |
Ok. I should have mentioned that its not working in my case .
I had to print the xml in pretty format like ..
Code: |
<ROOT>
<CHILD>1234</CHILD>
</ROOT> |
but i am getting this in a single line in the email mail body. like ..
Code: |
<ROOT><CHILD>1234</CHILD></ROOT> |
|
So you could (or actually have to) code it yourself: You have to go through the Input-XMLNSC-tree and put in the indentations yourself. Use a variable "nestingDepth" and use "REPLICATE(' ', nestingDepth)" to fill in the indentation. I had to / have coded something similar once.
You might use recursion but you can also just walk through the tree (without recursive calls). Probably you can use the ASBITSTREAM function on parts of the (input) message-tree (or probably not ... when I think of how namespaces work ). _________________ Just use REFERENCEs |
|
Back to top |
|
 |
mqjeff |
Posted: Sat Nov 03, 2012 6:09 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
mqsiuser wrote: |
Even though XML is machine readable this "embed xml (in an email) in a human readable way (pretty print)" is a really valid requirement. |
I completely disagree.
there are too many ways that it can be cleaned up in the presentation layer to support any method that requires it to be cleaned up in transit. |
|
Back to top |
|
 |
Vitor |
Posted: Sat Nov 03, 2012 7:09 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
mqsiuser wrote: |
Even though XML is machine readable this "embed xml (in an email) in a human readable way (pretty print)" is a really valid requirement. |
Valid for what requirement? Give 3 use cases where you would need to deliberately generate "pretty printed" XML, and 1 use case where such XML would be emailed to a receipient. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mqsiuser |
Posted: Sat Nov 03, 2012 7:22 am Post subject: |
|
|
 Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
Yes! It would be / it is difficult to write esql that pretty prints (xml).
So look: I am embedding the "tree" as pretty print into the email body.
Though/But/Additionally: You can attach the (actual) message (e.g. xml) (as a mime attachment)
All possible with the code (in the link) & sorry... it is for the old send-mail-plugin (I have created an issue that this should be migrated). |
|
Back to top |
|
 |
|