kprice | ef16068 | 2006-08-29 18:08:31 +0000 | [diff] [blame] | 1 | <?xml version="1.0" encoding="utf-8"?>
|
kprice | b59c9f6 | 2008-04-02 21:24:37 +0000 | [diff] [blame] | 2 | <!--Arbortext, Inc., 1988-2006, v.4002-->
|
| 3 | <!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN"
|
| 4 | "task.dtd">
|
kprice | ef16068 | 2006-08-29 18:08:31 +0000 | [diff] [blame] | 5 | <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,
|
| 11 | xsi:type support in the XML editor lets you choose between the complex type
|
| 12 | and any other complex types derived from it.</shortdesc>
|
| 13 | <taskbody>
|
| 14 | <context><p>The XML Schema specification allows you to derive types by extension.
|
kprice | b59c9f6 | 2008-04-02 21:24:37 +0000 | [diff] [blame] | 15 | See 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
|
| 20 | as <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>,
|
| 25 | and 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>,
|
| 28 | as <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
|
| 31 | xsi:type attribute will automatically be added to it.</cmd><info>For example, <codeblock><billTo xsi:type="ipo:Address"></codeblock>The
|
kprice | ef16068 | 2006-08-29 18:08:31 +0000 | [diff] [blame] | 32 | xsi:type attribute is used to identify derived complex types (as well as complex
|
kprice | b59c9f6 | 2008-04-02 21:24:37 +0000 | [diff] [blame] | 33 | types that have been derived from).</info></step>
|
| 34 | <step><cmd>In the Design view of the XML editor, a list will be available,
|
| 35 | letting you select the appropriate type definition (<uicontrol>Address</uicontrol>, <uicontrol>USAddress</uicontrol>,
|
| 36 | or <uicontrol>UKAddress</uicontrol>). The guided editing for the content
|
| 37 | model will reflect the type definition that you choose. For example, if you
|
| 38 | select <uicontrol>USAddress</uicontrol> , your <codeph>billTo</codeph> element
|
| 39 | can 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
|
kprice | ef16068 | 2006-08-29 18:08:31 +0000 | [diff] [blame] | 43 | more information about xsi:type, refer to the <b>Using Derived Types in Instance
|
| 44 | Documents</b> section in <xref format="html" href="http://www.w3.org/TR/xmlschema-0/#UseDerivInInstDocs"
|
| 45 | scope="external">XML Schema Part 0: Primer.</xref></p><p>For more information
|
| 46 | about validation semantics when xsi:type is used, refer to the <b>Schema-Related
|
| 47 | Markup in Documents Being Validated</b> section in <xref format="html" href="http://www.w3.org/TR/xmlschema-1/#xsi_type"
|
kprice | b59c9f6 | 2008-04-02 21:24:37 +0000 | [diff] [blame] | 48 | scope="external">XML Schema Part 1: Structures</xref> </p></postreq>
|
kprice | ef16068 | 2006-08-29 18:08:31 +0000 | [diff] [blame] | 49 | </taskbody>
|
| 50 | </task>
|
kprice | b59c9f6 | 2008-04-02 21:24:37 +0000 | [diff] [blame] | 51 | <?Pub *0000003154?>
|