Author |
Message
|
akkypaul |
Posted: Thu Jan 28, 2016 9:29 am Post subject: How to check for NULL or empty records for DFDL Messages |
|
|
 Apprentice
Joined: 30 Jun 2014 Posts: 44 Location: India
|
Which function can we used the best to ITERATE through a sequence of DFDL message (CSV Type)
Input Message Format:-
Head
-Field1
-Field2
-Field3
-Field4
Comes like
H1,F1,F2,F3,F4
H2,F1,F2,F3,F4
I was able to develop a message set which could successfully parse this message BUT I don't know what is the right way to traverse through this?
I tried using the following:-
COALESCE ->
WHILE COALESCE(InputRoot.DFDL.InputMsg.Rows[counter],'') = NULL DO
-> Does not gets inside the loop
IS NOT NULL ->
WHILE InputRoot.DFDL.InputMsg.Rows[counter] IS NOT NULL DO ->
Does not gets inside the loop
LASTMOVE ->
WHILE LASTMOVE(InputRoot.DFDL.InputMsg.Rows[counter]) DO
<Some Function gets executed>
MOVE InputRoot.DFDL.InputMsg.Rows NEXTSIBLING REPEAT NAME TYPE;
END WHILE;
- This gives me an error that says "MOVE InputRoot.DFDL.InputMsg.Rows NEXTSIBLING" has been used illegally.
CARDINALITY ->
DECLARE varTotalDataRecords INTEGER CARDINALITY(InputRoot.DFDL.InputMsg.Rows);
-> Gives me a deployment error stating that the CARDINALITY function needs a list as an input not NOT 1.
>>>> How is this possible that it is picking 1 when I am feeding a list to it?
So, nothing is working. Is there anyone who can explain me where am I wrong? |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Jan 28, 2016 9:50 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
It's not a DFDL message, or a CSV type.
It's a logical message tree.
You reference each piece of any logical message tree in the same way.
A basic read through of the ESQL functions available should provide you several easy ways to iterate over a set of child nodes, without having to do any of the poor ideas you've shown.
Also, consider what part of the message tree you are actually looping over. Is it Rows? Or the children of Rows? _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
akkypaul |
Posted: Thu Jan 28, 2016 9:59 am Post subject: It is the children of the rows and the rows |
|
|
 Apprentice
Joined: 30 Jun 2014 Posts: 44 Location: India
|
When I made the DFDL parser for this input message, I created a CSV message model 5 fields of comma separated values.
I used the LASTMOVE method in one of my previous interfaces where it worked perfectly.
I understand that once the message from the file has been parsed into the logical message tree, it can be treated like an XML and the iterative functions can be applied over it. But its not helping. |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Jan 28, 2016 10:01 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Again.
Are you looping over InputRoot.DFDL.InputMsg.Rows[counter], or InputRoot.DFDL.InputMsg.Rows ?
Again.
There are easier functions to use. _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
akkypaul |
Posted: Thu Jan 28, 2016 10:04 am Post subject: |
|
|
 Apprentice
Joined: 30 Jun 2014 Posts: 44 Location: India
|
UPDATE:-
CARDINALITY is working.
I used the wrong syntax for CARDINALITY which was not include the square brackets!!
CARDINALITY -> RESOLVED
DECLARE varTotalDataRecords INTEGER CARDINALITY(InputRoot.DFDL.InputMsg.Rows[]);
-> Deployed successfully and now I am able to traverse though the records based on the classic counter incremental method.
BUT, this is way too old and can hamper performance in long run.
I need a better reliable method which can simply check for NULLs or empty rows. |
|
Back to top |
|
 |
akkypaul |
Posted: Thu Jan 28, 2016 10:07 am Post subject: |
|
|
 Apprentice
Joined: 30 Jun 2014 Posts: 44 Location: India
|
@mqjeff
I am actually using a reference.
DECLARE inpRef REFERENCE TO InputRoot.DFDL.InputMsg.Rows[1];
WHILE LASTMOVE(inpRef) DO
<Some Function gets executed>
MOVE inpRef NEXTSIBLING REPEAT NAME TYPE;
END WHILE; |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Jan 28, 2016 10:19 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Ok.
So your message description doesn't show anything named "Rows". You show a bunch of header records, each of which has fields.
It's also not clear if you need to iterate over a set of elements named "Rows", or each child of a single element named "Rows".
It's also confusing to me that you have not bothered to go look for an easier function to use. Or if you have, you haven't mentioned it. _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
akkypaul |
Posted: Thu Jan 28, 2016 10:23 am Post subject: |
|
|
 Apprentice
Joined: 30 Jun 2014 Posts: 44 Location: India
|
|
Back to top |
|
 |
mqjeff |
Posted: Thu Jan 28, 2016 11:39 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
|
Back to top |
|
 |
akkypaul |
Posted: Thu Jan 28, 2016 12:19 pm Post subject: |
|
|
 Apprentice
Joined: 30 Jun 2014 Posts: 44 Location: India
|
Yes.
I am looping over the first option i.e. InputRoot.DFDL.InputMsg.Rows[].
The one without the DOT between Rows and Square Brackets [].
So, do you mean to say that I should be using
InputRoot.DFDL.InputMsg.Rows.[] when I am using the LASTMOVE way of iteration? |
|
Back to top |
|
 |
mqjeff |
Posted: Thu Jan 28, 2016 12:23 pm Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
I'm saying you need to use whichever one matches your logical message tree.
Which doesn't, apparently, match your message description. In that you didn't provide any relationship between "Rows" and "H1" or "H2" or etc.
And, I'm saying you should use the For statement, not anything else. _________________ chmod -R ugo-wx / |
|
Back to top |
|
 |
Vitor |
Posted: Thu Jan 28, 2016 12:24 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
akkypaul wrote: |
Yes.
I am looping over the first option i.e. InputRoot.DFDL.InputMsg.Rows[].
The one without the DOT between Rows and Square Brackets [].
So, do you mean to say that I should be using
InputRoot.DFDL.InputMsg.Rows.[] when I am using the LASTMOVE way of iteration? |
You should be using the one that correctly matches your message tree.
The dot means something; it describes the relationship between data items.
So Rows.[] and Rows[] are describing 2 different locations in the message tree. The first describes all the Rows in your tree. The second describes all the children of the first Rows in your tree. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
akkypaul |
Posted: Thu Jan 28, 2016 12:37 pm Post subject: |
|
|
 Apprentice
Joined: 30 Jun 2014 Posts: 44 Location: India
|
Thank you Vitor!
Quote: |
So Rows.[] and Rows[] are describing 2 different locations in the message tree. The first describes all the Rows in your tree. The second describes all the children of the first Rows in your tree. |
So, considering my input file looks like:-
H1,F1,F2,F3,F4
H2,F1,F2,F3,F4
H3,F1,F2,F3,F4
And after parsing, it becomes:-
MessageSet
-----Row
-------Header - H1
-------Field1 - F1
-------Field2 - F2
-------Field3 - F3
-------Field4 - F4
-----Row
-------Header - H2
-------Field1 - F1
-------Field2 - F2
-------Field3 - F3
-------Field4 - F4
-----Row
-------Header - H3
-------Field1 - F1
-------Field2 - F2
-------Field3 - F3
-------Field4 - F4
I should be using Row.[] so, that it has all the rows of the of the message. |
|
Back to top |
|
 |
Vitor |
Posted: Thu Jan 28, 2016 2:21 pm Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
akkypaul wrote: |
I should be using Row.[] so, that it has all the rows of the of the message. |
No, because I'm utterly insane and have clearly not taken my meds today!
Vitor wrote: |
So Rows.[] and Rows[] are describing 2 different locations in the message tree. The second describes all the Rows in your tree. The second describes all the children of the first Rows in your tree. |
Note the subtle but significant correction above.... (!)
Rows[] is the collection of Rows (3 in your example)
Rows.[] is the collection of 5 objects (H1 - F4) under the first Rows in your example, because of the dot. Rows[2].[] would be the second collection of objects H2 - F4 and so on.
I echo the advice of my most worthy associate; a FOR loop can and should be used to iterate such structures. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Simbu |
Posted: Fri Jan 29, 2016 1:58 am Post subject: |
|
|
 Master
Joined: 17 Jun 2011 Posts: 289 Location: Tamil Nadu, India
|
akkypaul wrote: |
@mqjeff
I am actually using a reference.
DECLARE inpRef REFERENCE TO InputRoot.DFDL.InputMsg.Rows[1];
WHILE LASTMOVE(inpRef) DO
<Some Function gets executed>
MOVE inpRef NEXTSIBLING REPEAT NAME TYPE;
END WHILE; |
Hi, FOR LOOP can be the best option for this which eliminated LASTMOVE and MOVE. |
|
Back to top |
|
 |
|