1. Konstantin Goldobin
  2. PowerBuilder
  3. Tuesday, 4 June 2019 14:35 PM UTC

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 @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 4 June 2019 18:35 PM UTC
  2. PowerBuilder
  3. # 1

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
  1. Konstantin Goldobin
  2. Wednesday, 5 June 2019 08:43 AM UTC
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. Helpful
  1. David Peace (Powersoft)
  2. Wednesday, 5 June 2019 09:00 AM UTC
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
  1. Helpful
There are no comments made yet.
David Peace (Powersoft) Accepted Answer Pending Moderation
  1. Tuesday, 4 June 2019 15:07 PM UTC
  2. PowerBuilder
  3. # 2

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
  1. Konstantin Goldobin
  2. Wednesday, 5 June 2019 08:44 AM UTC
What a bummer! I thought they could come up with expressions for tag names just like they did for element values...
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.