Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




Eclipse Web Tools Guide
Previous Page Home Next Page

Using xsi:type

If you have elements in your XML file whose type is a complex type, xsi:type support in the XML editor lets you choose between the complex type and any other complex types derived from it.

The XML Schema specification allows you to derive types by extension. See the following steps as an example:

  1. Create an XML schema and create a complex type for it called Address.
  2. Add some basic elements to Address, such as streetName and city.
  3. Derive (by extension) two new complex types from Address: USAddress and UKAddress.
  4. Add a new element to USAddress called state, and also a new element to UKAddress called postcode.
  5. Create two more elements: billTo and shipTo, as Address types.
  6. When you create an XML instance document for an element such as billTo or Address, an xsi:type attribute will automatically be added to it. For example,
    <billTo xsi:type="ipo:Address">
    The xsi:type attribute is used to identify derived complex types (as well as complex types that have been derived from).
  7. In the Design view of the XML editor, a list will be available, letting you select the appropriate type definition (Address, USAddress, or UKAddress). The guided editing for the content model will reflect the type definition that you choose. For example, if you select USAddress , your billTo element can contain a state element, but it cannot contain a postcode element.

The XML example "Editing and validating XML files" demonstrates xsi:type support.

For more information about xsi:type, refer to the Using Derived Types in Instance Documents section in XML Schema Part 0: Primer.

For more information about validation semantics when xsi:type is used, refer to the Schema-Related Markup in Documents Being Validated section in XML Schema Part 1: Structures

  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire