1. Konstantin Goldobin
  2. PowerBuilder
  3. Tuesday, 04 June 2019

Hello,

I was wondering how I can use a column value as an element name in a datawindow XML template. For example, if I have a data set:

var_name var_value

x             1
y             1
width       100
height      50

The default template would create two elements: var_name and var_value. What I would like to have in the exported XML file is elements x, y, width, and height with their corresponding values.

Best regards,
Konstantin

Chris Pollach Accepted Answer Pending Moderation
0
Votes
Undo

Hi Konstantin;

  Normally, this is quite easy once you know the approach and steps to perform.

For example:

1) Create a DWO with the base columns that you need.

2) Enter the SQL Painter and add the extra data to export as "Computed" Columns.

3) Upon return to the DW Painter, expand the XML pane

4) Use the RHMB on the XML template and add an XML Element, as follows:

5) Give the XML element a name (ie: "width"). Then use the RHMB on the new Element and add a Child and map that to a DWO column for that XML element, as follows:

6) repeat the above steps for all the SQL computed columns you wish to export.

7) Save the DWO. Then to test ... Retrieve and perform a SaveAs() in the DW Painter to an XML file.

8) View the XML file and it should be as you initially described.

9) If all looks OK at this point, add the DWO to your PB App. Loop through your DWO primary buffer and set the appropriate values of X, Y and Width just before you perform a SaveAs(XML!). That should do it!

HTH

Regards ... Chris

Comment
Hello Chris!

Thanks! But I don't have variables and their values as columns, I have them in rows like in the example table I used.

K
  1. Konstantin Goldobin
  2. Wednesday, 5 June 2019
Hi Chris



Your method only works if you have know KEY Names in the XML, if it is purely data driven as in this case then I think the only way is to generate the XML yourself.



Cheers

David
There are no comments made yet.
  1. Tuesday, 4 June 2019
  2. PowerBuilder
  3. # 1
0
Votes
Undo

I do not think you can get the DW template to generate dynamic XML.

You will have to build the XML yourself and if you are importing again parse the XML to read the data in.

Hope that helps.

David

Comment
What a bummer! I thought they could come up with expressions for tag names just like they did for element values...
  1. Konstantin Goldobin
  2. Wednesday, 5 June 2019
There are no comments made yet.
  1. Tuesday, 4 June 2019
  2. PowerBuilder
  3. # 2
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.