blob: dfc4641f263fbd2df5fa47a5ac6b1f646eac728d [file] [log] [blame]
kpriceef160682006-08-29 18:08:31 +00001<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
2<html lang="en-us" xml:lang="en-us">
syeshinbefd53e2005-07-27 18:16:40 +00003<head>
kpriceef160682006-08-29 18:08:31 +00004<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
kpriceb59c9f62008-04-02 21:24:37 +00005<meta name="copyright" content="Copyright (c) 2000, 2008 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at Contributors: IBM Corporation - initial API and implementation" />
6<meta name="DC.rights.owner" content="(C) Copyright 2000, 2008" />
kpriceef160682006-08-29 18:08:31 +00007<meta content="public" name="security" />
8<meta content="index,follow" name="Robots" />
9<meta http-equiv="PICS-Label" content='(PICS-1.1 "" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "" l gen true r (n 0 s 0 v 0 l 0) "" l gen true r (SS~~000 1))' />
10<meta content="task" name="DC.Type" />
11<meta name="DC.Title" content="Using xsi:type" />
12<meta name="abstract" content="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." />
13<meta name="description" content="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." />
14<meta content="XHTML" name="DC.Format" />
15<meta content="txsityp" name="DC.Identifier" />
16<meta content="en-us" name="DC.Language" />
17<link href="../../org.eclipse.wst.doc.user/common.css" type="text/css" rel="stylesheet" />
syeshinbefd53e2005-07-27 18:16:40 +000018<title>Using xsi:type</title>
syeshin66078272005-09-20 16:53:38 +000019</head>
syeshinbefd53e2005-07-27 18:16:40 +000020<body id="txsityp"><a name="txsityp"><!-- --></a>
kpriceef160682006-08-29 18:08:31 +000022
syeshinbefd53e2005-07-27 18:16:40 +000023<h1 class="topictitle1">Using xsi:type</h1>
kpriceef160682006-08-29 18:08:31 +000024
syeshinbefd53e2005-07-27 18:16:40 +000027<div><p>If you have elements in your XML file whose type is a complex type,
28xsi:type support in the XML editor lets you choose between the complex type
kpriceef160682006-08-29 18:08:31 +000029and any other complex types derived from it.</p>
31<div class="section"><p>The XML Schema specification allows you to derive types by extension.
kpriceb59c9f62008-04-02 21:24:37 +000032See the following steps as an example:</p>
36<li class="stepexpand"><span>Create an XML schema and create a complex type for it called <kbd class="userinput">Address</kbd>. </span>
39<li class="stepexpand"><span>Add some basic elements to <kbd class="userinput">Address</kbd>, such
40as <kbd class="userinput">streetName</kbd> and <kbd class="userinput">city</kbd>.</span>
43<li class="stepexpand"><span>Derive (by extension) two new complex types from <kbd class="userinput">Address</kbd>: <kbd class="userinput">USAddress</kbd> and <kbd class="userinput">UKAddress</kbd>. </span></li>
45<li class="stepexpand"><span>Add a new element to <kbd class="userinput">USAddress</kbd> called <kbd class="userinput">state</kbd>,
46and also a new element to <kbd class="userinput">UKAddress</kbd> called <kbd class="userinput">postcode</kbd>.</span>
49<li class="stepexpand"><span>Create two more elements: <kbd class="userinput">billTo</kbd> and <kbd class="userinput">shipTo</kbd>,
50as <tt class="sysout">Address</tt> types.</span></li>
52<li class="stepexpand"><span>When you create an XML instance document for an element such as
53 <tt class="sysout">billTo</tt> or <kbd class="userinput">Address</kbd>, an
54xsi:type attribute will automatically be added to it.</span> For example, <pre>&lt;billTo xsi:type="ipo:Address"&gt;</pre>
syeshinbefd53e2005-07-27 18:16:40 +000056xsi:type attribute is used to identify derived complex types (as well as complex
kpriceb59c9f62008-04-02 21:24:37 +000057types that have been derived from).</li>
59<li class="stepexpand"><span>In the Design view of the XML editor, a list will be available,
60letting you select the appropriate type definition (<span class="uicontrol">Address</span>, <span class="uicontrol">USAddress</span>,
61or <span class="uicontrol">UKAddress</span>). The guided editing for the content
62model will reflect the type definition that you choose. For example, if you
63select <span class="uicontrol">USAddress</span> , your <samp class="codeph">billTo</samp> element
64can contain a <samp class="codeph">state</samp> element, but it cannot contain a <samp class="codeph">postcode</samp> element.</span>
69<div class="section"><p>The XML example "Editing and validating XML files" demonstrates <strong>xsi:type</strong> support.</p>
syeshinbefd53e2005-07-27 18:16:40 +000070<p>For
kpriceef160682006-08-29 18:08:31 +000071more information about xsi:type, refer to the <strong>Using Derived Types in Instance
72Documents</strong> section in <a href="" target="_blank">XML Schema Part 0: Primer.</a></p>
73<p>For more information
74about validation semantics when xsi:type is used, refer to the <strong>Schema-Related
75Markup in Documents Being Validated</strong> section in <a href="" target="_blank">XML Schema Part 1: Structures</a> </p>
syeshinbefd53e2005-07-27 18:16:40 +000076</div>
kpriceef160682006-08-29 18:08:31 +000077
syeshinbefd53e2005-07-27 18:16:40 +000078</div>
kpriceef160682006-08-29 18:08:31 +000079
syeshinbefd53e2005-07-27 18:16:40 +000081</body>