xml spy
Previous  Top  Next
Importing hierarchical data - Data shaping (ADO)

XML Spy allows you to import hierarchical database data using the ADO data shaping function. This allows you to re-import specific parts of external databases.

You can either write your own selection strings or have XML Spy automatically create them using the Create Database schema and then the XML Import based on DB Schema commands.

To be able to use data shaping you have to use:
·The MSDataShape provider  
·The special Data shape language, which is a subset of SQL  
 
Both these modules are available if you have installed Microsoft Data Access Components Version 2.6 or later.

To import hierarchical data into XML Spy:

1.Select the menu option Convert | Import Database data...  
tut_s1_odb6  
2.Click the ADO connection string radio button, and then the Build button.  
tut_s1_odb7  
3.Double click the MSDataShape entry in the list box.  
This automatically switches you to the Connection tab.  
tut_s1_odb8  
4.Enter "shape" in the Data Source field.  
5.Click on the "Test Connection" button (at the bottom of the dialog box), if you want to make sure you can connect to the database - and then click OK to close the Test connection message box.  
6.Click OK to close the Data Link Properties dialog box.  
tut_s1_odb9  
The ADO connection string now appears in the text box.  
7.Open the shape.txt file supplied with the tutorial; copy the first Shape select statement, and paste it into the Selection statement text box.  
tut_s1_odb10  
8.Click the "Preview" button to see a portion of the database data.  
tut_s1_odb11  
·Only the top level (parent) of the database data, defined by the shape command, is visible in the preview window.  


Defining how the parent elements will be imported
The preview window allows you to directly select and define the field data you want to import.

Clicking repeatedly on the element symbol ic_element to the left of the element name, cycles through the available possibilities:

ic_elementDefine and import this field as an Element.  
ic_attribDefine and import this field as an Attribute.  
ic_del_fieldSkip, do not import this field.  

Please note:  
You can only directly influence the parent elements that you see here. You cannot change or choose to skip any elements below these ones (i.e. child elements).  

Defining how the child elements will be imported

While the shape string allows you to import child objects, you can only define that all child items are to be imported as Elements or Attributes.

·Select either the Elements by default or Attributes by default option, to define how you want to import the child elements. The preview is updated when you select one of these options.  
·Activate or deactivate the "Exclude Primary/Foreign keys" check box, to define if you want to import the data with or without primary or foreign keys.  
·Activate or deactivate the "Create empty elements from empty fields" check box, to define if you want empty elements to be created for those fields that do not contain any data.  
 
Please note:  
The selections you make here initially apply to the parent items as well. Changing parent items directly, takes precedence over these settings, but only applies to the parent elements and not to any child elements.  
Clicking the Preview button, resets any changes made to the parent elements in the Preview view.  
 
Starting the data import
1.Click the OK button of the Database import dialog box, when you have completed your definition of the data you want to import.  
 
XML Spy creates an untitled XML file containing the Division and Person table data. The root element is called Import, and each Division element is a table row. Each Division element also contains the Person child elements, displayed in table form.  
tut_s1_odb12  
Click the Row element and press F9 (or click the Display as Table icon ic_disp_as_tbl ) to remove the table formatting. Each Division element is now displayed separately.  
tut_s1_odb13  



Previous  Top  Next

© 2002 Altova