xml spy
Previous  Top  Next
References, attributes and enumerations

To finish off the schema definition we will make the Person element global, define specific element attributes and limit the attribute selection.

To create a reference:
1.Switch to the Schema overview ic_back2global (Display all Globals).  
2.Click on the component icon of the ic_component Company element.  
3.Right click the Person element, and select Make Global | Element.  
A small "link" icon appears in the Person element, showing that this element now references the globally declared "Person" element. The "isRef" field in the Details entry helper is set active.  

   tut_23a

4.Click the "Display all Globals" icon ic_back2global to return to the schema overview.  
The Person element is now also visible in the component list, as well as in the "Elm" tab of the Component navigator. Click the Elm tab to see the global elements.  

tut_24a  

Please note:  
Global declarations do not describe where an element is to be used in an XML document, they only describe what it contains. Global definitions have to be referenced from within a complex type, or another element, to determine their position in the XML document.  
 
To define Element attributes:
1.Click the Person element to make it active.  
2. Click the Append icon, in the top left of the attribute tab (the lower window of the schema overview), and select the "Attribute" entry.  

tut_24b  

3.Enter "Manager" as the attribute name in Name field.  
4.Use the Type combo box to select "xs:boolean".  
5.Use the Use combo box to select "required".  

tut_25a  

6.Use the same method to:  
Add a "Programmer" attribute in the Name field (type="xs:boolean), and set its Use to "optional".  

To l
imit the contents of an attribute (Enumerations):
1. Click the Append icon in the top left of the attribute window, and select the "attribute" entry.  
2.Enter "Degree" as the attribute name, and select "xs:string" as the attribute type.  
3.Click the Enumerations tab of the Facets entry helper.  

tut_25b  

4.Click the Append icon ic_schem_appof the Enumerations tab and enter "BA", confirm with Enter.  
5.Use the same method to add two more items to the enumerations list ("MA" and "Ph.D").  

The finished schema should look like this:  

tut_26a  

6.Select the menu command File | Save, and save the file as AddressLast.xsd.  
 
Please note:  
This schema is available as 'AddressLast.xsd' in the Tutorial folder.  

Previous  Top  Next

© 2002 Altova