Prodataset & xml

Hope this code helps
define temp-table ttAPI xml-node-name "ItemMaster"
field cComponent as character xml-node-name "part"
field cDesc as character xml-node-name "Desc" .
define temp-table ttAPISite xml-node-name "ItemSite"
field cpart as character xml-node-name "part"
field csite as character xml-node-name "Desc" .

define dataset dsttAPI {1}
for ttAPI,ttAPISite
data-relation qcm1 for ttAPI,ttAPISite nested
relation-fields (cComponent,cpart).
create ttAPI.
cComponent = "AAA".
cdesc = "XXXXXXXXXXXXX".
create ttAPISite.
cpart = "AAA".
csite = "402".
create ttAPI.
cComponent = "BBB".
cdesc = "YYYYYYYYYYYYY".
create ttAPISite.
cpart = "BBB".
csite = "402".
create ttAPI.
cComponent = "CCC".
cdesc = "ZZZZZZZZZZZZZ".
create ttAPISite.
cpart = "CCC".
csite = "402".
dataset dsttAPI:write-xml("FILE","tst.xml").
 
First, the ProDataSet does not write an XML request or an XML response. The READ-XML() and WRITE-XML() functions on the ProDataSet object handle are not designed for that. The READ-XML() function is designed to read from what was created with WRITE-XML() from an already existing ProDataSet in the first place.

You need to roll your own logic to create the request XML and parse the response XML either using DOM or SAX. You can use Temp-Table and a ProDataSet to work with the data in your application that is not necessarily so.

I think that what you need are code snippets to create and parse XML documents ...

Heavy Regards, RealHeavyDude.
 
I am sorry if that was confusing.

My initial post had a Request XML & a Response XML. All I need is to write and read those XML files using PRODATASETS.
  1. Currently i am done writing the XML from PRODATASETS Data using WRITE-XML() function
  2. We have passed this XML successfully to a 3rd party application using Webservice that will use this XML (which i have referred as Request XML) for processing
  3. Once the application is done with its processing it sends back an XML (which i have referred as Response XML) to progress
  4. I am stuck at this point - When i read the XML using READ-XML() function and fetch the values using a Dynamic PRODATASETS; progress throws me an error saying the XML doesn't have a defined relationship (I am really not worried about the Relationship - all i need is to use the data that comes back from the XML that the 3rd party application provides)

Now - I need to know either one of below;
  1. If we could successfully use READ-XML() to read the XML file (name - Response.XML) and store them either on a DATASET or as a collection of temp-tables. How would the PRODATASET look like?
  2. If the relationship is what stopping us to read the XML i would like to know how should the XML file look like and what needs to be added so that READ-XML() function can read the XML successfully

I hope i conveyed it better this time. Please let me know if you need more details.
 
The READ-XML() function most likely will not work when the XML was not created with Progress using the WRITE-XML() function in the first place. That is because they are designed that way and are not configurable apart from the ProDataSet definition and the Temp-Table it contains. Full stop. You might be lucky to get it working but I would not spend much time for trying out.

If I were you I would parse the XML with the SAX or DOM parser, preferably the SAX parser. There is a book called "Working with XML" contained in the documentation which describes how both work which you can find here http://communities.progress.com/pcom/docs/DOC-16074 if you don't already have it.

Heavy Regards, RealHeavyDude.
 
Are you sure about this? I am surprised.

I saw in a trusted PRO-DATASET PPT that says;

WRITE-XML() & WRITE-XMLSCHEMA() sends the data to Non-Progress and READ-XML() & READ-XMLSCHEMA() receives and reads the XML from Non-Progress.

There should be a way definitely that READ-XML reads the attached XML (ResponseXML.txt - probably when i ran i saved teh file with extension .xml). I am receiving couple of errors here;

Error Numbers - 9033, 9044, 13174, 13040. I am sure we should be able to resolve them 1 by 1.

This might be even silly; writing an XSD that says this is how READ-XML() function will have to read my XML? Wild guess.
 
WRITE-XML() & WRITE-XMLSCHEMA() sends the data to Non-Progress and READ-XML() & READ-XMLSCHEMA() receives and reads the XML from Non-Progress.

that's certainly true, it does not really matter who produced the XML as long as Progress can infer the dataset schema and dynamically create the dataset or you can define the dataset schema yourself and if the XML match that it will load without problems.

the 'response' xml looks more like a SOAP web-service response, why don't you call the web-service and save yourself from troubles of building the 'request' and parse the 'response'... if you can get the WSDL calling it from OE10+ should be very easy... don't know the version you have at hand though :)

if that is not an option then you'll have to define somehow the dataset structure yourself, for one I see there is a 'seller' and 'customer' information (should map to a temp-table) both at top response level and at the 'line item' level... the table structures seems not to be the same so I wont blame Progress for not being able to figure it out what kind of information is in there (different entities with the same name).
 
Back
Top