blob: 32ed973cdcde28fabc67217507f2ade307e3fcbd [file] [log] [blame]
kpriceef160682006-08-29 18:08:31 +00001<?xml version="1.0" encoding="utf-8"?>
kpriceb59c9f62008-04-02 21:24:37 +00002<!--Arbortext, Inc., 1988-2006, v.4002-->
3<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN"
4 "task.dtd">
kpriceef160682006-08-29 18:08:31 +00005<task id="txsityp" xml:lang="en-us">
6<title>Using xsi:type</title>
7<titlealts>
8<searchtitle>Using xsi:type</searchtitle>
9</titlealts>
10<shortdesc>If you have elements in your XML file whose type is a complex type,
11xsi:type support in the XML editor lets you choose between the complex type
12and any other complex types derived from it.</shortdesc>
13<taskbody>
14<context><p>The XML Schema specification allows you to derive types by extension.
kpriceb59c9f62008-04-02 21:24:37 +000015See the following steps as an example<?Pub Caret?>:</p></context>
16<steps>
17<step><cmd>Create an XML schema and create a complex type for it called <userinput>Address</userinput>. </cmd>
18</step>
19<step><cmd>Add some basic elements to <userinput>Address</userinput>, such
20as <userinput>streetName</userinput> and <userinput>city</userinput>.</cmd>
21</step>
22<step><cmd>Derive (by extension) two new complex types from <userinput>Address</userinput>: <userinput>USAddress</userinput> and <userinput>UKAddress</userinput
23>. </cmd></step>
24<step><cmd>Add a new element to <userinput>USAddress</userinput> called <userinput>state</userinput>,
25and also a new element to <userinput>UKAddress</userinput> called <userinput>postcode</userinput>.</cmd>
26</step>
27<step><cmd>Create two more elements: <userinput>billTo</userinput> and <userinput>shipTo</userinput>,
28as <systemoutput>Address</systemoutput> types.</cmd></step>
29<step><cmd>When you create an XML instance document for an element such as
30 <systemoutput>billTo</systemoutput> or <userinput>Address</userinput>, an
31xsi:type attribute will automatically be added to it.</cmd><info>For example, <codeblock>&lt;billTo xsi:type="ipo:Address"></codeblock>The
kpriceef160682006-08-29 18:08:31 +000032xsi:type attribute is used to identify derived complex types (as well as complex
kpriceb59c9f62008-04-02 21:24:37 +000033types that have been derived from).</info></step>
34<step><cmd>In the Design view of the XML editor, a list will be available,
35letting you select the appropriate type definition (<uicontrol>Address</uicontrol>, <uicontrol>USAddress</uicontrol>,
36or <uicontrol>UKAddress</uicontrol>). The guided editing for the content
37model will reflect the type definition that you choose. For example, if you
38select <uicontrol>USAddress</uicontrol> , your <codeph>billTo</codeph> element
39can contain a <codeph>state</codeph> element, but it cannot contain a <codeph>postcode</codeph> element.</cmd>
40</step>
41</steps>
42<postreq><p>The XML example "Editing and validating XML files" demonstrates <b>xsi:type</b> support.</p><p>For
kpriceef160682006-08-29 18:08:31 +000043more information about xsi:type, refer to the <b>Using Derived Types in Instance
44Documents</b> section in <xref format="html" href="http://www.w3.org/TR/xmlschema-0/#UseDerivInInstDocs"
45scope="external">XML Schema Part 0: Primer.</xref></p><p>For more information
46about validation semantics when xsi:type is used, refer to the <b>Schema-Related
47Markup in Documents Being Validated</b> section in <xref format="html" href="http://www.w3.org/TR/xmlschema-1/#xsi_type"
kpriceb59c9f62008-04-02 21:24:37 +000048scope="external">XML Schema Part 1: Structures</xref> </p></postreq>
kpriceef160682006-08-29 18:08:31 +000049</taskbody>
50</task>
kpriceb59c9f62008-04-02 21:24:37 +000051<?Pub *0000003154?>