|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Introducing Line breaks in esql |
« View previous topic :: View next topic » |
Author |
Message
|
GeneRK4 |
Posted: Wed Apr 02, 2014 1:06 am Post subject: Introducing Line breaks in esql |
|
|
Master
Joined: 08 Jul 2013 Posts: 220
|
I want to display something like below in am XML message,
<Name>
A,B
C,D
E,F
G,H
</Name>
I tried using the below statement for achieving this,
DECLARE LF CHAR;
SET LF = CAST(x'0A' AS CHAR CCSID InputRoot.MQMD.CodedCharSetId) ;
SET OutputRoot.XMLNSC.Name = 'A' || '}' || 'B' || '}' || LF || 'A' || '}' || 'B' ;
The output is produced with \n character inserted .
In notepad ,editplus and wordpad,I am able to see the linebreak.
But in RFHUTIL,Internet explorer ,I am not able to see the output xml message with the Linebbreak.It is coming as below,
<Name>
A,B C,D E,F G,H
</Name>
Any suggestions on how we can view the expected output in IE?Is this something to be done in esql through java? |
|
Back to top |
|
 |
McueMart |
Posted: Wed Apr 02, 2014 1:14 am Post subject: |
|
|
 Chevalier
Joined: 29 Nov 2011 Posts: 490 Location: UK...somewhere
|
|
Back to top |
|
 |
kimbert |
Posted: Wed Apr 02, 2014 3:35 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
Quote: |
I want to display something like below in am XML message,
<Name>
A,B
C,D
E,F
G,H
</Name> |
This is not a good idea. You should not design XML formats where the formatting of text is significant. There are at least two good reasons for this
1. XML parsers must collapse all sequences of line break characters ti a single line break. I know you are using a single line break - but will the next developer understand why you made that decision?
2. The rest of the world does it differently. So even if you get it to work you will have created a maintenance problem.
A better way to do it would be
Code: |
<Name>
<foo>A,B</foo>
<foo>C,D</foo>
<foo>E,F</foo>
<foo>G,H</foo>
</Name> |
If there are exactly 2 subfields for every 'foo' tag then you could add those as subtags or XML attributes.
You have decided to use XML. So follow the conventions of XML, and work with the standard, not against it. _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
mqsiuser |
Posted: Wed Apr 02, 2014 4:55 am Post subject: |
|
|
 Yatiri
Joined: 15 Apr 2008 Posts: 637 Location: Germany
|
kimbert wrote: |
1. XML parsers must collapse all sequences of line break characters ti a single line break. |
http://stackoverflow.com/questions/2986297/line-break-in-xml
In XML a line break is a normal character. You can do this:
Code: |
<xml>
<text>some text
with
three lines</text>
</xml> |
and the contents of <text> will be
Code: |
some text
with
three lines |
If this does not work for you, you are doing something wrong. Special "workarounds" like encoding the line break are unnecessary. Stuff like \n won't work, on the other hand, because XML has no escape sequences*. _________________ Just use REFERENCEs |
|
Back to top |
|
 |
kimbert |
Posted: Wed Apr 02, 2014 5:01 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
More correctly:
"In XML a line break is a normal character that will be converted to a single linefeed ( Unicode character 0x0A ) by the XML parser." _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
mqjeff |
Posted: Wed Apr 02, 2014 5:26 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
See Data.
See Data mangle.
CDATA |
|
Back to top |
|
 |
kimbert |
Posted: Wed Apr 02, 2014 7:39 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
In case anybody misunderstands mqjeff's point, I will extend that sentence once more:
"In XML a line break is a normal character that will be converted to a single linefeed ( Unicode character 0x0A ) by the XML parser even if the line break occurs within a CDATA section."
A CDATA section can be very useful, but it is not as powerful as most people think. _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
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
|
|
|
|