READ-XMLSCHEMA and nested multi-level datasets

Hi - I'm trying to create a dynamic ProDataset from an XSD file, manually populate the tables, and then export the dataset as formatted XML.

The Dataset is created just fine from the XSD file, and I can populate both the root level table and the first level down. When I populate any data a third level into the dataset, the third-level data is NOT exported when I execute hDSET:WRITE-XML.

Sample code is pasted below, and the response is missing two levels of detail (vhPickupType and vhShipper). The full XSD is attached to this post (It's the standard UPS Rate Request). Any advice would be greatly appreciated!


Code:
DEFINE VARIABLE hDSET AS HANDLE NO-UNDO.
DEFINE VARIABLE vhRateRequest AS HANDLE NO-UNDO.
DEFINE VARIABLE vhRequest     AS HANDLE NO-UNDO.
DEFINE VARIABLE lReturn AS LOGICAL NO-UNDO.

DEFINE VARIABLE vhTransactionReference AS HANDLE NO-UNDO.
DEFINE VARIABLE vhPickupType           AS HANDLE NO-UNDO.
DEFINE VARIABLE vhShipment             AS HANDLE NO-UNDO.
DEFINE VARIABLE vhShipper              AS HANDLE NO-UNDO.


CREATE DATASET hDSET.


CREATE DATASET vhRateRequest.

lReturn = vhRateRequest:READ-XMLSCHEMA("FILE", "/home/ups/request.xsd", ?, ?, ?).

ASSIGN vhRequest = vhRateRequest:GET-BUFFER-HANDLE("Request").
vhRequest:BUFFER-CREATE().
vhRequest:BUFFER-FIELD("RequestAction"):BUFFER-VALUE = "Create".

ASSIGN vhShipment = vhRateRequest:GET-BUFFER-HANDLE("Shipment").
ASSIGN vhShipper  = vhRateRequest:GET-BUFFER-HANDLE("Shipper").


vhShipment:BUFFER-CREATE().
ASSIGN vhShipment:BUFFER-FIELD("Description"):BUFFER-VALUE = "SHIPPER 01".

vhShipper:BUFFER-CREATE().
ASSIGN vhShipper:BUFFER-FIELD("Name"):BUFFER-VALUE = "Test Name".

ASSIGN vhPickupType = vhRateRequest:GET-BUFFER-HANDLE("PickupType").
vhPickupType:BUFFER-CREATE().

vhPickupType:BUFFER-FIELD("Code"):BUFFER-VALUE = 101.
vhPickupType:BUFFER-FIELD("Description"):BUFFER-VALUE = "TEST Description".

lReturn =  vhRateRequest:WRITE-XML("FILE", "/home/ups/request.xml",
TRUE, ?, ?, TRUE, TRUE).

message "Return is: " lReturn view-as alert-box.


The Result that I have (missing data) is:
Code:
<?xml version="1.0"?>
<RatingServiceSelectionRequest xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Request>
    <RequestAction>Create</RequestAction>
    <RequestOption/>
  </Request>
  <PickupType>
    <Code>101</Code>
    <Description>TEST Description</Description>
  </PickupType>
  <Shipment>
    <Description>SHIPPER 01</Description>
  </Shipment>
</RatingServiceSelectionRequest>
 

Attachments

  • request.zip
    982 bytes · Views: 5

Stefan

Well-Known Member
Nice. I think you are running into the note section of read-xml-schema:
Note: The XML document must be an XML Schema written in the XML Schema Definition (XSD) language in the 2001 XML Schema namespace (http://www.w3.org/2001/XMLSchema). Non-OpenEdge applications might use XSD in many ways. The READ-XMLSCHEMA( ) method attempts to parse any XSD elements that form an obvious relational structure into ABL temp-tables and ProDataSets. However, the method might not be able to handle every XSD element generated by a non-OpenEdge source. The closer a particular XSD element conforms to what the WRITE-XMLSCHEMA( ) method creates, the more likely that the READ-XMLSCHEMA( ) method will succeed.
So you will need to define / model the ProDataSet yourself.
 
Thanks for the quick response! I did see that note; I was hoping that since the READ-XMLSCHEMA command correctly created the dataset (the tables are getting defined) that the data in those lower-level tables would be exported. I appreciate the help.
 
Top