xml spy
Previous  Top  Next
Database/Table view

Database/Table view: ic_disp_as_tbl
The Database /Table view is available wherever the Enhanced Grid view can be activated, and can be used when editing any type of XML file - XML, XSD, XSL etc.

Advantages:
·Drag and drop column headers  
·Sort column (table) data using the menu command XML | Table | Ascending Sort  
·Append (or insert) rows using the menu command XML | Table | Insert Row.  
·Copy and paste structured data to and from third party products  
·Intelligent entry help  

Activating the Database/Table view:

1.Click on or near, Person element text in the grid view (this marks the person element).  

tut_50a  
2.Select the menu option XML | Table | Display as table, or click the Display as table ic_disp_as_tbl icon (Hotkey F9).  
The Person elements have now been combined into a single table. The Element and Attribute names are now the column headers, and the element contents (values) are now the rows of the table.  
3.Select the menu option View | Optimal widths, or click the Optimal widths icon, ic_opt_widths to optimize the table view.  

tut_51a  

Please note:  
The element and attribute entry helpers also function in the Database/Table view. The element entry helper now displays the mandatory !Person element; double clicking it would add a new row to the table.  

4.Double click in the "Manager" cell of row 2, and select "false". Use the Tab key to get to the next cells, and select the following data: Degree=MA, Programmer=true, First=Alfred, Last=Aldrich, PhoneExt=33 and EMail=Aldrich@work.  

tut_51b  

Please note:  
The F9 key switches between Grid view and Database/Table view, of the currently selected table or recurring element.  

Copying XML data to and from third party products
XML Spy allows you to easily copy data to and from third party products. The copied data can be used within XML Spy as well as third-party products, enabling you to transfer XML data to spreadsheet-like applications (e.g. Microsoft Excel).

Copying XML data to and from Excel:

1.Click on the row label 1, hold down the CTRL key and click on row label 2.  
This marks both rows of the table.  

tut_51c  

2.Select the menu option Edit | Copy as Structured text.  
The "Copy as Structured Text" command, copies elements to the clipboard as they appear on screen.  
3.Switch to Excel and paste the XML data in an Excel worksheet.  

tut_52a  

4.Enter a new row of data in Excel. Make sure that you enter a three digit number for the PhoneExt element (e.g. 444).  

tut_52b  

5.Mark the table data in Excel, select Edit | Copy, and switch back to XML Spy.  
6.Click in the top left cell of the table data in XML Spy, and select Edit | Paste.  

tut_52c  

The updated table data is now visible in the table.  

7.Change the uppercase boolean values, "TRUE/FALSE", to lowercase "true/false" using the menu option Edit | Replace (Hotkey CTRL+H).  

Sorting data in the Database/Table view ic_sort_a
The Database/Table view allows you to sort your XML table data by any column you wish. In this case we want to sort our table by last names.

1.Click on the Last column header. This marks the whole column.  

tut_52d  

2.Select the menu option XML | Table | Ascending sort, or click on the "Ascending sort" icon.  
The column and whole table are now been sorted alphabetically (the column remains marked).  

tut_53a  

This sorting procedure affects your data at source level. (Click the Text view icon if you want to see the changes there.)  
3.Select the menu option XML | Validate, or hit the F8 key.  
An error message appears: "This file is not valid: Value does not match facet maxInclusive="99" in element 'PhoneExt'.  

tut_53b  

The offending element is automatically marked in the Database/table view. We need more telephone extensions!  
 
Updating a schema definition ic_goto_def
At this point that we realize that two digit phone extensions are definitely not enough, and that we would like to allow for three digits. To do this we have to make a change to the underlying schema document.

1.Select the menu option DTD/Schema | Go to definition or click the "Go to definition" icon.  
The associated schema document, in this case AddressLast.xsd, is opened in the Schema overview.  

tut_53c  

2.Click the "component" icon ic_component of the global Person element, and then click the PhoneExt element. You can now see the facet data in the facets tab.  

tut_54a  

3.Click the "maxIncl" cell containing the facet data, enter 999, and confirm with Enter.  

tut_54b  

4.Hit CTRL+TAB to switch back to the XML document.  
5.Click the "Revalidate" button to revalidate the XML document.  

tut_54c  

The "This file is valid" message appears. The XML document now conforms to the changed schema definition!  

tut_55a  

6.Select the menu option File | Save As... and name the XML document (e.g. CompanyLast.xml).  
7.Hit CTRL+TAB to switch back to the schema document, and save the schema document.  

The XML document is available as 'CompanyLast.xml' in the Tutorial folder.  

Previous  Top  Next

© 2002 Altova