Author |
Message
|
schroederms |
Posted: Fri Apr 04, 2008 8:34 am Post subject: REFERENCE to a reoccurring data tag in an XML message. |
|
|
 Disciple
Joined: 21 Jul 2003 Posts: 169 Location: IA
|
The statement below returns the data, but I what I need is a reference to the data for this reoccuring "item" tag so I can append data to it.
Set Environment.FindTheRow =
The(Select t.OUT From OutputRoot.XMLNSC.DATA.item[] as t
where t.OUT like Environment.ResultString[i]);
But what I really need to do instead is set a reference to it so I can modify it, however I do not know what the value (occurance number) is of item[].
Any ideas?
Thanks.
A small sample input XML would be
<DATA>
<item>
<OUT>|2008|1100|10|1L|11LN|LNB|010|31G65||SP|0001000040|</OUT>
</item>
<item>
<OUT>|2008|1100|10|1L|11LN|LNB|010|31G65||SP|0001110504|</OUT>
</item>
<item>
<OUT>|2008|1100|10|1L|11LN|LNB|010|31G65||SP|0001119382|</OUT>
</item>
<item>
<OUT>|2008|1100|10|1L|11LN|LNB|010|31G65||SP|0001172073|</OUT>
</item>
<item>
<OUT>|2008|1100|10|1L|11LN|LNB|010|31G65||SP|0001218622|</OUT>
</item>
<item>
<OUT>|2008|1100|10|1L|11LN|LNB|010|31G65||SP|0001388604|</OUT>
</item>
<item>
<OUT>|2008|1100|10|1L|11LN|LNB|010|31G65||SP|0001448194|</OUT>
</item>
<item>
<OUT>|2008|1100|10|1L|11LN|LNB|010|31G65||SP|0001448599|</OUT>
</item>
</DATA> |
|
Back to top |
|
 |
wbi_telecom |
Posted: Fri Apr 04, 2008 8:44 am Post subject: |
|
|
 Disciple
Joined: 15 Feb 2006 Posts: 188 Location: Harrisburg, PA
|
Move the reference to the Item[i] where I = 1. Check LASTMOVE = TRUE..Apend data. Do this in a loop by incrementing the value of i. End the loop anytime you get LASTMOVE = FLASE.
Cheers, |
|
Back to top |
|
 |
jefflowrey |
Posted: Fri Apr 04, 2008 11:18 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
wbi_telecom wrote: |
Move the reference to the Item[i] where I = 1. Check LASTMOVE = TRUE..Apend data. Do this in a loop by incrementing the value of i. End the loop anytime you get LASTMOVE = FLASE. |
No.
Use MOVE instead of incrementing I.
Code: |
declare reference myRef =OutputRoot.XMLNSC.Data.item;
while lastmove...
move myRef nextsibling; |
or etc. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
schroederms |
Posted: Mon Apr 07, 2008 6:29 am Post subject: |
|
|
 Disciple
Joined: 21 Jul 2003 Posts: 169 Location: IA
|
Appreciate the help, but still confused. This is the code I have in place. The appending of the data, always is occuring on the first <OUT> tag listed in the XML, not the one found by the SELECT.
Set Environment.FindTheRow[1] = null;
--This finds the correct occurence of the <OUT> tag.... working correctly.
Set Environment.FindTheRow =
The(Select t.OUT From OutputRoot.XMLNSC.DATA.item[] as t
where t.OUT like Environment.ResultString[i]);
If Exists(Environment.FindTheRow.OUT[]) then
set Environment.Item[i].Found = 'YES';
set Environment.Item[i].Total_Invoiced = cast Environment.TOTAL_INVOICED as char);
--Declare a reference to the data I thought was found in the about SELECT..... NOT working correctly.
Declare myResultRef reference to OutputRoot.XMLNSC.DATA.item;
Set Environment.Item[i].Value_Before = myResultRef;
--Append data to the occurrence found.
--This code is always appending to the first <OUT> tag found in the XML, not the one I want from the about SELECT.
Set myResultRef.OUT = myResultRef.OUT || cast (Environment.TOTAL_INVOICED as char) || '|';
Set Environment.Item[i].Value_Final = myResultRef.OUT;
Else
set Environment.Item[i].Found = 'NO';
end if; |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Apr 07, 2008 6:32 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
declare myref REFERENCE TO the(Select t.OUT From OutputRoot.XMLNSC.DATA.item[] as t
where t.OUT like Environment.ResultString[i]);
Which may not work. _________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
schroederms |
Posted: Mon Apr 07, 2008 6:46 am Post subject: |
|
|
 Disciple
Joined: 21 Jul 2003 Posts: 169 Location: IA
|
I've tried that in the past, and tried again, but get a Syntax error. a reference declaration must not like a SELECT result... ??? |
|
Back to top |
|
 |
jefflowrey |
Posted: Mon Apr 07, 2008 7:01 am Post subject: |
|
|
Grand Poobah
Joined: 16 Oct 2002 Posts: 19981
|
Yes, I think this is likely.
SAMEFIELD might be a possibility, but you're still ending up having to walk the tree twice...
You might be able to declare a reference to Environment.FindTheRow... but I don't know if that will work either.
It may be better to build the explicit loop and not try to shortcut with SELECT...
Code: |
Declare myResultRef reference to OutputRoot.XMLNSC.DATA.item;
while lastmove myref...
if myRef.OUT LIKE Environment.ResultString[i]
set Environment.Item[i].Found = 'YES';
set Environment.Item[i].Total_Invoiced = ...
...
end if
move myRef nextsibling repeat type name;
end while... |
_________________ I am *not* the model of the modern major general. |
|
Back to top |
|
 |
schroederms |
Posted: Mon Apr 07, 2008 7:10 am Post subject: |
|
|
 Disciple
Joined: 21 Jul 2003 Posts: 169 Location: IA
|
I agree. Thanks for your help. |
|
Back to top |
|
 |
|