Author |
Message
|
EnOne |
Posted: Tue Apr 12, 2005 12:54 pm Post subject: Attributes in the Environment |
|
|
 Centurion
Joined: 09 Oct 2002 Posts: 100 Location: Kansas City
|
using MQv5.3 and WBIMBv5.0
I am trying to do my work in the compute nodes within the Environment tree like so...
SET OutputRoot.XML.Parent.Child[1] = 'Pebbles';
SET OutputRoot.XML.Parent.Child[2] = 'BamBam';
SET Environment.XML = OutputRoot.XML;
SET OutputRoot.XML = NULL;
this keeps me from have to copy the entire XML tree (SET OutputRoot = InputRoot; )everytime I go into a compute node. Now I only copy the headers and do my transformations within the Environment tree which allows my flow to execute faster.
(my actual XML tree is much larger but this is enough to explain my problem)
It was all working fine until I tried
SET OutputRoot.XML.Parent.Child[1] = 'Pebbles';
SET OutputRoot.XML.Parent.Child[1].(XML.Attribute)type = 'F';
SET OutputRoot.XML.Parent.Child[2] = 'BamBam';
SET OutputRoot.XML.Parent.Child[2].(XML.Attribute)type = 'M';
SET OutputRoot.XML.Parent.(XML.Attribute)mom = 'Wilma';
SET OutputRoot.XML.Parent.(XML.Attribute)dad = 'Fred';
SET Environment.XML = OutputRoot.XML;
SET OutputRoot.XML = NULL;
which should have created
<Parent mom='Wilma' dad='Fred'>
<Child type='F'>Pebbles</Child>
<Child type='M'>BamBam</Child>
</Parent>
When I tried to put the message back into XML it only returned the following
<Parent>
<Child>Pebbles</Child>
<Child>BamBam</Child>
</Parent>
the mom and dad attributes on Parent were missing. I checked the XML and mom and dad are a part of parent before they go in Environment, but not when they come out. Is there a simple way to set Attributes so they can survive the Environment tree? |
|
Back to top |
|
 |
JT |
Posted: Tue Apr 12, 2005 1:23 pm Post subject: |
|
|
Padawan
Joined: 27 Mar 2003 Posts: 1564 Location: Hartford, CT.
|
To copy XML attributes, you have to use the FIELDVALUE function.
Based on your example however, doesn't it make more sense to set the elements in the Environment tree directly?
Code: |
SET Environment.XML.Parent.Child[1] = 'Pebbles';
SET Environment.XML.Parent.Child[1].(XML.Attribute)type = 'F';
SET Environment.XML.Parent.Child[2] = 'BamBam';
SET Environment.XML.Parent.Child[2].(XML.Attribute)type = 'M';
SET Environment.XML.Parent.(XML.Attribute)mom = 'Wilma';
SET Environment.XML.Parent.(XML.Attribute)dad = 'Fred';
|
You'll save yourself the overhead incurred from the copy/nullify of the OutputRoot tree. |
|
Back to top |
|
 |
EnOne |
Posted: Tue Apr 12, 2005 4:46 pm Post subject: |
|
|
 Centurion
Joined: 09 Oct 2002 Posts: 100 Location: Kansas City
|
This flow is a part of many flows when that call different procedures. When the information leaves the flow then it needs to be as an XML message with the attributes intact. Within the flow I would like for it to be within the Environment tree. write an individual line of code that converts all of the attributes into elements then passes these elements into the Environment tree and at the end convert these elements back to attributes but I was hoping for something a little simpler like an Environment version of attribute.
I'm thinking you are suggesting transforming
<Parent mom='Wilma' dad='Fred'>
<Child type='F'>Pebbles</Child>
<Child type='M'>BamBam</Child>
</Parent>
into
<Environment>
<XML>
<Parent>
<mom>Wilma</mom>
<dad>Fred</fred>
<Child>Pebbles</Child>
<Child>BamBam</Child>
<type>F</type>
<type>M</type>
</Parent>
</XML>
</Environment>
and then transforming it back to XML when I'm done with it. |
|
Back to top |
|
 |
JT |
Posted: Wed Apr 13, 2005 5:31 am Post subject: |
|
|
Padawan
Joined: 27 Mar 2003 Posts: 1564 Location: Hartford, CT.
|
No, I'm suggesting you set the elements & attributes in the Environment tree instead of the OutputRoot tree, and then when you need the elements & attributes set in the OutputRoot tree, use the FIELDVALUE function against the Environment tree. |
|
Back to top |
|
 |
nathanw |
Posted: Fri Apr 15, 2005 2:38 am Post subject: |
|
|
 Knight
Joined: 14 Jul 2004 Posts: 550
|
except of course that Bambam is Barney and Bettys child not Fred and Wilmas
Last edited by nathanw on Fri Apr 15, 2005 5:19 am; edited 1 time in total |
|
Back to top |
|
 |
mgk |
Posted: Fri Apr 15, 2005 3:32 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
The statement:
Code: |
SET Environment.XML = OutputRoot.XML; |
does not create an XML parser in the environment. For this to work
you need to create an XML parser using the CREATE statement with the DOMAIN clause before you do this assignment.
Once you have CREATEd an XML parser then you can assign elements to and their attributes will be intact. _________________ 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 |
|
 |
jfluitsm |
Posted: Sat Apr 16, 2005 12:16 pm Post subject: |
|
|
Disciple
Joined: 24 Feb 2002 Posts: 160 Location: The Netherlands
|
|
Back to top |
|
 |
|