xml spy
Previous  Top  Next
Creating and completing a new XML file

To create a new XML document:
1.Select the menu option File | New, and select the .xml XML Document entry from the dialog, then confirm with OK.  

tut_35a  

A prompt appears, asking if you want to base the XML document on a DTD or Schema.  
2.Click the Schema radio button, and confirm with OK.  

tut_35b  

A further dialog appears, asking you to select the schema file your XML document is to be based on.  

3.Use the Browse or Window buttons to find the schema file, in our case the AddressLast schema, and confirm the selection with OK.  

tut_35c  

An XML document containing the main elements defined by the schema, opens in the main window. XML documents are automatically opened in the Enhanced Grid View.  
 
Please note:  
XML Spy tries to find the root element of a schema automatically. The "Select a root element" dialog box is opened, if it is unclear which is the root element. You can then select the root element manually.  

tut_36a  

4.Click on any element to deselect the data.  
5.Click on the ic_expand_elem icon next to Address, to view the Address sub-elements.  

tut_36b  

Making elementType definitions available in XML documents
The Address elements we see in the grid view are those that were defined by the global complex type "AddressType". We would, however, like to access the specific AddressTypes we defined: UK- and US-Address.

1.Right click the Name element, and select Insert | Attribute from the context menu.  
An attribute field is added to the Address element, and a popup containing xsi:type automatically opens.  

tut_37a  

2.Hit the "Tab" key to move into the next field.  
3.Select US-Address from the drop-down list, and confirm with Enter.  

tut_37b  

Please note:  
The xsi prefix allows you to use special XML Schema related commands in your XML document instance. Please see the W3C website at http://www.w3.org/TR/2001/REC-xmlschema-0-20010502 for more information.  

Entering (and deleting) data

1.Double click in the Name value field (or use the arrow keys) and enter "US dependency", confirm with Enter.  

tut_37c  

2.Use the same method to enter a Street and City name (e.g. Noble Ave. and Dallas).  
3.Click the Person element, and hit the "Del" key to delete it (we will add it again in a few moments in the Text view!).  
4.Click on any Address element to deselect the elements.  
Your XML document should look like this:  

tut_38a  

Previous  Top  Next

© 2002 Altova