Author |
Message
|
KSkelton |
Posted: Tue Jul 22, 2003 5:53 am Post subject: Unique XML to Repeating XML |
|
|
Apprentice
Joined: 28 Oct 2001 Posts: 45
|
WMQI 2.1
Is there any easy way to convert unique XML tags into a repeating structure?
<block><field1> data </field1></block>
<block><field2> data </field2></block>
<block><field3> data </field3></block>
converted to
<block>
<field> data </field>
<field> data </field>
<field> data </field>
</block> |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Jul 22, 2003 6:27 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Yes, you should be able to code this with a select. See the ESQL reference manual for more help. |
|
Back to top |
|
 |
KSkelton |
Posted: Tue Jul 22, 2003 9:17 am Post subject: |
|
|
Apprentice
Joined: 28 Oct 2001 Posts: 45
|
Jeff,
Thanks, but I do not see how a select will help.
I need to reference the various field names and change them into a single field name. All of the select logic (in the manual) refers to a single field name to begin with.
Is there a way to anonymously reference an unknown number of fields?
See xml above... |
|
Back to top |
|
 |
KSkelton |
Posted: Tue Jul 22, 2003 1:06 pm Post subject: |
|
|
Apprentice
Joined: 28 Oct 2001 Posts: 45
|
Well I figured out the following using the .*[] anonymous reference.
Wish there was a better way because now I have to figure out just how many of the anonymous fields there are and what their staring position (loopcount) is going be.
declare loopcount integer;
set loopcount = 3;
declare outcount integer;
set outcount = 1;
while outcount <= 3 DO
SET OutputRoot.XML.OUT.BLOCK.FIELD[outcount] = coalesce(InputRoot.XML.IN.*[loopcount],'');
SET loopcount = loopcount + 1;
SET outcount = outcount + 1;
end while; |
|
Back to top |
|
 |
jefflowrey |
Posted: Tue Jul 22, 2003 1:55 pm Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
KSkelton wrote: |
Jeff,
Thanks, but I do not see how a select will help.
I need to reference the various field names and change them into a single field name. All of the select logic (in the manual) refers to a single field name to begin with. |
Something vaguely like
Code: |
set OutputRoot.XML.OUT.BLOCK[] = (Select X.(XML.Content).* as FIELD from InputRoot.XML.BLOCK as X where X.(XML.Element) like 'field%'); |
I think the ESQL Reference guide has some specific examples of doing exactly the kind of transformation you're looking to do. |
|
Back to top |
|
 |
|