Example – PB Docs 2017

Example

This example uses a DataWindow object that includes the
columns emp_id, emp_fname, emp_lname, and dept_id. The template used
in this example includes only these columns. Any other columns in
the DataWindow remain empty when you import using this
template.

To illustrate how template import works, create a new template
that has one element in the header section, called
before_detail_marker. This element contains a column reference to
the emp_id column.

The Detail Start element, employee, has an attribute, dept_id,
whose value is a control reference to the column dept_id. It also
has three children:

  • The emp_id element contains a column reference to the
    emp_id column.

  • The emp_fname element contains static text.

  • The name element has two children, emp_fname and
    emp_lname, that contain column references to those
    columns.

dwimp2.gif

The template exports and imports the dept_id DataWindow column
using the attribute of the employee element. It exports and imports
the emp_id, emp_fname, and emp_lname columns using the column
references in the elements. The following shows the beginning of the
XML exported using this template:

The exported XML can be reimported into the DataWindow columns
dept_id, emp_id, emp_fname, and emp_lname. Before importing, you
must set the import template on the Data Import page in the
Properties view or in a script using the DataWindow object’s
Import.XML.UseTemplate property.

The following items are exported, but ignored on
import:

  • The before_detail_marker element is ignored because it is
    in the header section.

  • The first occurrence of the element tag name emp_fname is
    ignored because it does not contain a mapping to a DataWindow
    column name.

If you change the nesting of the emp_fname and emp_lname
elements inside the name element, the import fails because the order
of the elements and the nesting in the XML and the template must
match.


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x