Author |
Message
|
MrSmith |
Posted: Mon Aug 13, 2012 6:55 am Post subject: Behavioural question on XML style format |
|
|
Master
Joined: 20 Mar 2008 Posts: 215
|
I was playing with some lines of code whereby i am creating an XML "style" output (i.e. its not true XML but is element based etc
So I tried this
Reference outRef_Header points to OutputRoot.XMLNSC.DOC
Code: |
CREATE LASTCHILD OF outRef_header NAME 'ELEMENTNUMBER1' VALUE 'XMLOUT ELEMENT1';
CREATE LASTCHILD OF outRef_header VALUE CAST(x'0A' as character ccsid InputRoot.MQMD.CodedCharSetId);
CREATE LASTCHILD OF outRef_header NAME 'ELEMENTNUMBER2' VALUE '';
CREATE LASTCHILD OF outRef_header VALUE CAST(x'0A' as character ccsid InputRoot.MQMD.CodedCharSetId);
DECLARE tmp_ELEMENT3 CHAR 'FRED';
CREATE LASTCHILD OF outRef_header NAME 'ELEMENTNUMBER3' VALUE tmp_ELEMENT3;
CREATE LASTCHILD OF outRef_header VALUE CAST(x'0A' as character ccsid InputRoot.MQMD.CodedCharSetId); |
The result being
<DOC>
<ELEMENTNUMBER1>XMLOUT ELEMENT1</ELEMENTNUMBER1>[eol character]
<ELEMENTNUMBER2>[eol character]</ELEMENTNUMBER2>[eol character]
<ELEMENTNUMBER3>FRED</ELEMENTNUMBER3>[eol character]
</DOC>[eol character]
Now the poitn was to have each element on a different line when displayed (like you get in rfhutil for instance BUT when the value is empty i.e. an empty tag is inserts an additional eol character in between the beginning element and the closing one of the same name and i dont see why, it only happens on empty assigned values, if the value is set then its fine
Help on how the write occurs in broker in that does the pointer actually point to a "location" after the beginning tag then write the value then close the tag as can not see why it would put one in between if the ESQL defines it as a LASTCHILD of the parent reference
Broker 6.1.09 on windows not that should make any difference per se
Thanks _________________ -------- *
“Outside of a dog, a book is man's best friend. Inside of a dog it's too dark to read.” |
|
Back to top |
|
|
lancelotlinc |
Posted: Mon Aug 13, 2012 7:51 am Post subject: |
|
|
Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
I think you may be amiss in your assumption that you need to place an EOL character in your XML document. Human-readable formatting is done at display time, not at XML document create time. Opening an XML document in IE will automatically insert CR/LF after each element. The XML as it exists on the disk will not have the CR/LF characters.
To say it another way, don't put CR/LF in your XML stream. It's not needed or desired. _________________ http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER |
|
Back to top |
|
|
mqjeff |
Posted: Mon Aug 13, 2012 8:03 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
lancelotlinc wrote: |
To say it another way, don't put CR/LF in your XML stream. It's not needed or desired. |
EDIT: There's also a strong argument to be made that XML documents are never intended for user display, but only for machine consumption to create user display.
There's also a significant XML-standard distinction between the EOL character here:
Code: |
<ELEMENTNUMBER2>[eol character]</ELEMENTNUMBER2> |
and the one here
Code: |
</ELEMENTNUMBER2>[eol character]<ELEMENTNUMBER3> |
The first one is part of the value of the element, and the second one is mixed-content.
Oddly enough, since the XML standard makes a huge distinction between the two, the XMLNSC parser handles them differently. |
|
Back to top |
|
|
MrSmith |
Posted: Mon Aug 13, 2012 8:57 am Post subject: |
|
|
Master
Joined: 20 Mar 2008 Posts: 215
|
lancelotlinc wrote: |
I think you may be amiss in your assumption that you need to place an EOL character in your XML document. Human-readable formatting is done at display time, not at XML document create time. Opening an XML document in IE will automatically insert CR/LF after each element. The XML as it exists on the disk will not have the CR/LF characters.
To say it another way, don't put CR/LF in your XML stream. It's not needed or desired. |
Gents a bit of credit please I am aware of that and the XML standards etc but this is a client request, for their client who it would appear can not even spell XML - they wont change their custom parser or app to use a "proper" XML parser and altho it prob more closely qualifies to a TDS i.e just a string which happens to contain XML type characters and an EOL repeater I am not allowed to do that either hence if you got any info on how the tags are written in XMLNSC parser maybe I can work around it cos I have no choice
TBH its **** but sometimes it dont mtter how hard you push for reason it eludes us _________________ -------- *
“Outside of a dog, a book is man's best friend. Inside of a dog it's too dark to read.” |
|
Back to top |
|
|
lancelotlinc |
Posted: Mon Aug 13, 2012 9:03 am Post subject: |
|
|
Jedi Knight
Joined: 22 Mar 2010 Posts: 4941 Location: Bloomington, IL USA
|
|
Back to top |
|
|
MrSmith |
Posted: Mon Aug 13, 2012 9:10 am Post subject: |
|
|
Master
Joined: 20 Mar 2008 Posts: 215
|
lancelotlinc wrote: |
Then write it out as a BLOB. Don't use the XMLNSC parser. |
Tried the BLOB route of ASBITSTREAMING from the Root through each FolderLevel (FolderStream) and replacing "><" with ">lf<" but you still get the issue of where ELEMENTNUMBER2 ends up like <ELEMENTNUMBER2>lf</ELEMENTNUMBER2>lf at least I though the other way of LASTCHILD would get round that cos it should only write the EOL AFTER the closing tag _________________ -------- *
“Outside of a dog, a book is man's best friend. Inside of a dog it's too dark to read.” |
|
Back to top |
|
|
mqjeff |
Posted: Mon Aug 13, 2012 9:27 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
|
Back to top |
|
|
MrSmith |
Posted: Tue Aug 14, 2012 3:45 am Post subject: |
|
|
Master
Joined: 20 Mar 2008 Posts: 215
|
mqjeff wrote: |
http://publib.boulder.ibm.com/infocenter/wmbhelp/v7r0m0/topic/com.ibm.etools.mft.doc/ac67195_.htm |
mqjeff - looked at the mixed content thing first tbh (presume thats what you were referring to?)
so I tried it
Still comes out with th EOL in between the tags if the value is empty... _________________ -------- *
“Outside of a dog, a book is man's best friend. Inside of a dog it's too dark to read.” |
|
Back to top |
|
|
mqjeff |
Posted: Tue Aug 14, 2012 4:35 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Yes, that's the way mixed-content should work. It refers to things that are children of tags but not tags themselves. i.e.
Code: |
<msg><tag1>here<tag2>not here</tag2></tag1></msg> |
If the intent is to add a CR LF or just an LF after each tag, then using LASTCHILD as you did is correct, but you do have to retain mixed-content for it to be serialized.
You always have the option of using a non-Broker xml formatter, perhaps from a JavaCompute node, and output a BLOB instead of an XMLNSC tree. |
|
Back to top |
|
|
mgk |
Posted: Tue Aug 14, 2012 4:43 am Post subject: |
|
|
Padawan
Joined: 31 Jul 2003 Posts: 1639
|
Can you post the output of a trace node showing the tree after the compute node where you created you example below...
Kind regards, _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
Back to top |
|
|
|