Consultor Eletrônico



Kbase P125790: READ-XML method fails to populate dataset
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/09/2007
Status: Unverified

FACT(s) (Environment):

All Supported Operating Systems
OpenEdge 10.1B

SYMPTOM(s):

READ-XML method fails to populate dataset

Trying to populate a dataset with an XML file created from another dataset fails.

Creating a dynamic dataset from another dataset with the CREATE-LIKE method

** FIND FIRST/LAST failed for table . (565)

For example:

/* Create an XML file from the source dataset - buffer name ttCustomer */
dataset dsCustomer:write-xml('file','d:\temp\customer.xml',yes,?,?,yes).


/* Create a copy of the source dataset but prefix its buffers with "xy", e.g. xyttCustomer */
create dataset hPDS.
hPDS:create-like(dataset dsCustomer:handle,'xy':U).

/* Read the XML file into the dataset copy */
hPDS:read-xml('file','d:\temp\customer.xml',?,?,?).

hPDS:get-buffer-handle(1):find-first().

This code will fail with error 565 because the READ-XML has failed to populate the dataset.

CAUSE:

This is because the buffer name of the ProDataSet is different from the buffer name used in the XML file buffer nodes.

The original dataset that created the XML file with the WRITE-XML method uses a different buffer name 'ttCustomer', so the XML buffer nodes have been created using the original name. But the new ProDataSet uses the prefix 'xy' for its buffers, and this is the reason the READ-XML fails.

FIX:

To resolve this problem use the new OpenEdge 10.1B dataset buffer XML-NODE-NAME attribute, and set this to the same buffer name as that used in the XML file. For example:

Modify the code so that the copy dataset is created as before, but the XML-NODE-NAME attribute is set to the same value as the original ProDataSet buffer.

/* Create a copy of the source dataset but prefix its buffers with "xy", e.g. xyttCustomer */
create dataset hPDS.
hPDS:create-like(dataset dsCustomer:handle,'xy':U).

/* get handle to target dataset buffer */
h1 = hPDS:get-buffer-handle(1).

/* Set the new prodataset buffer XML-NODE-NAME attribute, to the same value as the original dataset buffer name */
/* e.g. from 'xyttCustomer' to 'ttCustomer' */
h1:XML-NODE-NAME = DATASET dsCustomer:HANDLE:get-buffer-handle(1):XML-NODE-NAME.

The find-first method will now work correctly.