Is there a bug in hNode:GET-CHILD() ?

Kirmik

Member
I have an odd scenario where handle:GET-CHILD() is falling over with the error:
X-NODEREF or X-DOCUMENT GET-CHILD got an error: Invalid child index. (9082)
X-NODEREF must be associated with a valid X-DOCUMENT in order to use it in method NODE-VALUE. (9102)

I know what these errors mean but to be honest I think it's a bug. I'll explain why...

The process I run to load in the XML document has been running fine until recently. After spending a lot of time looking for a fault in the XML document I've discovered that the one thing that has changed is that instead of filling out one of the fields with blank spaces where no value exists the XML provider is no putting out an empty element.
eg.

What was: <AddressLine2> </AddressLine2>
becomes: <AddressLine2></AddressLine2>


As far as I'm aware this is still valid XML so why would GET-CHILD() produce an error when it wasnt before?


Any ideas?

Here's an extract from the code. It's not dynamic yet and will be reworked at a later stage:-



CASE hNode5:NAME:
WHEN "Title":U THEN
DO:
hNode5:GET-CHILD(hNode6, 1).

IF hNode6:NAME = "#TEXT" THEN
ASSIGN ttDebt.drTitle = hNode6:NODE-VALUE.
END.
WHEN "S":U THEN
DO iDrDet = 1 TO hNode5:NUM-CHILDREN:
hNode5:GET-CHILD(hNode6, iDrDet).

hNode6:GET-CHILD(hNode7,1). /* This is where the error occurs when the element value is null */

CASE hNode6:NAME:
WHEN "FirstName":U THEN
ttDebt.drfName = hNode7:NODE-VALUE.
WHEN "Surname":U THEN
ttDebt.lstName = hNode7:NODE-VALUE.
WHEN "ContactNumber1":U THEN
ttDebt.phone1 = hNode7:NODE-VALUE.
WHEN "ContactNumber2":U THEN
ttDebt.phone2 = hNode7:NODE-VALUE.
WHEN "AddressLine1":U THEN
ttDebt.adr1 = hNode7:NODE-VALUE.
WHEN "AddressLine2":U THEN
ttDebt.adr2 = hNode7:NODE-VALUE.
WHEN "AddressLine3":U THEN
ttDebt.adr3 = hNode7:NODE-VALUE.
WHEN "City":U THEN
ttDebt.city = hNode7:NODE-VALUE.
WHEN "PostCode":U THEN
ttDebt.pCode = hNode7:NODE-VALUE.
WHEN "InstallationDateOfFirstService":U THEN
ttDebt.instDOFS = hNode7:NODE-VALUE.
WHEN "DisconnectDateOfLastService":U THEN
ttDebt.disDOLS = hNode7:NODE-VALUE.
END CASE. /* hNode6 */
 

Kirmik

Member
Yes Koz you were right n this one. I managed to find the answer


I'd found out that when there is no data value in the XML then it's considered null so the node has no child and would cause an error when you call GET-CHILD on it.
eg.
<AddressLine2 /> /* This is null */
<AddressLine2></AddressLine2>/* This is null */
<AddressLine2>anything</AddressLine2>/* This has a value of "anything" */
<AddressLine2> </AddressLine2>/* This has a value of " " */


Thanks for the replys guys :)


 
Top