|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
How can I add a line feed to a XML element ? |
« View previous topic :: View next topic » |
Author |
Message
|
ernest-ter.kuile |
Posted: Tue May 14, 2002 4:55 am Post subject: How can I add a line feed to a XML element ? |
|
|
 Apprentice
Joined: 13 May 2002 Posts: 49 Location: KLM Holland
|
Hi all,
I need to include a series of strings to a xml element (for the context, it's an email body) without losing the formating.
I tried adding a 
 using a XML.AsisElementContent typecast,
but when I read back the existing element using the same cast the system seems to loop.
let me explain using pseudo code. What I need is to append an array of 'text' to itself and add a line feed between each line. the result is placed in the OutputRoot.XML...
if 'text' was clean, and did not have any chars that need escaping in anyway, then what *would* work (sort of) is this:
Code: |
SET data = ''; -- initilise intermediate result.
loop (a) until no more text
-- add one line of text
SET data = data || string [a] || '
';
end loop;
SET XML.data.(XML.AsisElementContent) = data; |
Unfortunatly 'text' does have chars that need escaping.
So I split the above statement in two, forgo the intermediate variable and directly place my text in the XML element to have the system escape the relevant characters.
Read back the same string Asis (all illegale chars stay escaped), add an already escaped line feed (
) and place Asis back in the XML element.
This is what I tried:
Code: |
SET XML.data = ''; -- initilise result.
loop (a) until no more text
-- add one line of text
SET XML.data = XML.data || string [a];
-- add line feed
SET XML.data.(XML.AsisElementContent) =
XML.data.(XML.AsisElementContent) || '
';
end loop |
However this does not work, the system loops until the broker is reset.
(note that I don't get any warning or error about the contruct)
what am I doing wrong ?
Is there a different way to have the system escape the chars in a string for inclusion into an XML element ?
How can I include a line feed (or any unprintable char) to a string without changing it to a BLOB first ?
Thanks.
Ernest ter Kuile |
|
Back to top |
|
 |
Salty |
Posted: Tue May 14, 2002 5:37 am Post subject: |
|
|
Newbie
Joined: 14 May 2002 Posts: 1
|
you can add a line feed by simply:
-- add line feed
SET XML.data.(XML.AsisElementContent) =
XML.data.(XML.AsisElementContent) || '
'; |
|
Back to top |
|
 |
ernest-ter.kuile |
Posted: Tue May 14, 2002 7:02 am Post subject: |
|
|
 Apprentice
Joined: 13 May 2002 Posts: 49 Location: KLM Holland
|
That does not compute.
Doing it that way (using XML.AsisElementContent) would literaly add a line feed to the XML flow. This would then be discarded (as it should) by anything parsing the XML.
To effectively add a line feed it has to be escaped
It seems like a good idea though to try this without the (XML.AsisElementContent).
SET data = data || text[a] || '
';
Hmmm, looks fishy. :-?
Last edited by ernest-ter.kuile on Tue May 14, 2002 7:40 am; edited 1 time in total |
|
Back to top |
|
 |
ernest-ter.kuile |
Posted: Tue May 14, 2002 7:20 am Post subject: |
|
|
 Apprentice
Joined: 13 May 2002 Posts: 49 Location: KLM Holland
|
Wel ...
to my great surprise
Code: |
SET data = data || '
';
|
actually does add a line feed to the string !!
Try that in C.
To my great frustration however
Code: |
SET OutputRoot.XML.data = data; |
did not escape the inserted line feed to a required 
, but adds it literally as if XML.AsisElementContent had been used.
Anybody knows how I can force a conversion ? |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|