ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » XML in email body

Post new topic  Reply to topic Goto page 1, 2  Next
 XML in email body « View previous topic :: View next topic » 
Author Message
firoj.badsa
PostPosted: Wed Oct 31, 2012 12:16 pm    Post subject: XML in email body Reply with quote

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
View user's profile Send private message
mqjeff
PostPosted: Wed Oct 31, 2012 12:22 pm    Post subject: Reply with quote

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
View user's profile Send private message
firoj.badsa
PostPosted: Wed Oct 31, 2012 12:32 pm    Post subject: Reply with quote

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
View user's profile Send private message
kimbert
PostPosted: Wed Oct 31, 2012 1:10 pm    Post subject: Reply with quote

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
View user's profile Send private message
firoj.badsa
PostPosted: Wed Oct 31, 2012 11:21 pm    Post subject: Reply with quote

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
View user's profile Send private message
mqjeff
PostPosted: Thu Nov 01, 2012 1:25 am    Post subject: Reply with quote

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
View user's profile Send private message
firoj.badsa
PostPosted: Thu Nov 01, 2012 5:59 am    Post subject: Reply with quote

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
View user's profile Send private message
kimbert
PostPosted: Thu Nov 01, 2012 6:11 am    Post subject: Reply with quote

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
View user's profile Send private message
firoj.badsa
PostPosted: Thu Nov 01, 2012 6:19 am    Post subject: Reply with quote

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
View user's profile Send private message
mqjeff
PostPosted: Thu Nov 01, 2012 6:27 am    Post subject: Reply with quote

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
View user's profile Send private message
Vitor
PostPosted: Thu Nov 01, 2012 6:42 am    Post subject: Reply with quote

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
View user's profile Send private message
mqsiuser
PostPosted: Fri Nov 02, 2012 11:00 pm    Post subject: Reply with quote

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
View user's profile Send private message
mqjeff
PostPosted: Sat Nov 03, 2012 6:09 am    Post subject: Reply with quote

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
View user's profile Send private message
Vitor
PostPosted: Sat Nov 03, 2012 7:09 am    Post subject: Reply with quote

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
View user's profile Send private message
mqsiuser
PostPosted: Sat Nov 03, 2012 7:22 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » XML in email body
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.