XML to Prodataset - children without ID's

Posted by Jens Dahlin on 23-Aug-2012 04:59

As a follow up to my post last week (Calling an URL) I've got a new question.

If I want to handle XML's and do it in a not so old-fashioned way ProDatasets has to be the answer. Given the xml below, how can I get relation between Transfer and Rates? How do I know which Rates entry thats related to a given Transfer entry (and which Inbound_Rate that belongs to a specific Rates etc)?

Also: do I really need a Rates table since that only is a tag containing other tags (no data in itself).

<transfer>
  <LocID>14483</LocID>
  <LocationFrom>Airport TLL (Tallinn)</LocationFrom>
  <LocationTo>Parnu</LocationTo>
  <Duration>0</Duration>
  <Distance>0</Distance>
  <Transfer_Type_ID>1</Transfer_Type_ID>
  <Transfer_Type>Taxi</Transfer_Type>
  <Num_Transfers>1</Num_Transfers>
<Rates>
<Inbound_Rate>
  <Rate_Id>1</Rate_Id>
  <Rate>171.6</Rate>
  </Inbound_Rate>
<OutBound_Rate>
  <Rate_Id>2</Rate_Id>
  <Rate>171.6</Rate>
  </OutBound_Rate>
<Both_Rate>
  <Rate_Id>3</Rate_Id>
  <Rate>343.2</Rate>
  </Both_Rate>
  </Rates>
  <Price_Policy>per unit</Price_Policy>
</transfer>
<transfer>
  <LocID>14484</LocID>
  <LocationFrom>Airport TLL (Tallinn)</LocationFrom>
  <LocationTo>Riga</LocationTo>
  <Duration>0</Duration>
  <Distance>0</Distance>
  <Transfer_Type_ID>1</Transfer_Type_ID>
  <Transfer_Type>Taxi</Transfer_Type>
  <Num_Transfers>1</Num_Transfers>
<Rates>
<Inbound_Rate>
  <Rate_Id>1</Rate_Id>
  <Rate>279.8</Rate>
  </Inbound_Rate>
<OutBound_Rate>
  <Rate_Id>2</Rate_Id>
  <Rate>279.8</Rate>
  </OutBound_Rate>
<Both_Rate>
  <Rate_Id>3</Rate_Id>
  <Rate>559.6</Rate>
  </Both_Rate>
  </Rates>
  <Price_Policy>per unit</Price_Policy>
</transfer>

All Replies

Posted by Peter Judge on 23-Aug-2012 08:37

+1 for the title/subject

If I want to handle XML's and do it in a not so old-fashioned way

ProDatasets has to be the answer. Given the xml below, how can I get

relation between Transfer and Rates? How do I know which Rates entry thats

related to a given Transfer entry (and which Inbound_Rate that belongs to

a specific Rates etc)?

This depends somewhat on the version. In 11.0 there's a new PARENT-ID-RELATION relationship type you can add to the dataset definition, which can help with inferring relationships on read. You could also use an XSD which defines the relationships on load.

Also: do I really need a Rates table since that only is a tag containing

other tags (no data in itself).

Yes. Each level of the XML document needs to conform to a table.

-- peter

Posted by Jens Dahlin on 23-Aug-2012 08:53

Changed the title from "Parental Issues" to something a bit more descriptive...

Well, unfortunently I'm on 10.2B. Trying to make some kind of event (currently focusing of ROW-CREATE) fire when one the parent/child entries are created. That could solve it but I can't seem to get it to work.

This thread is closed