blob: ef5c946629e2bf817ba991b5501f234bd26cc3e4 [file] [log] [blame]
kprice159fa582006-05-08 21:30:45 +00001<?xml version="1.0" encoding="utf-8"?>
2<!--Arbortext, Inc., 1988-2005, v.4002-->
kprice647b7352006-05-17 21:27:16 +00003<!DOCTYPE task PUBLIC "-//OASIS//DTD DITA Task//EN"
4 "task.dtd">
5<?Pub Inc?>
kprice159fa582006-05-08 21:30:45 +00006<task id="taddcmxt" xml:lang="en-us">
7<title>Adding complex types</title>
8<titlealts>
9<searchtitle>Adding complex types</searchtitle>
10</titlealts>
11<shortdesc>A complex type allows elements in its content and can carry attributes.
12Complex types can be used to help determine the appropriate content for any
13instance documents generated from or associated with your XML schema.</shortdesc>
14<prolog><metadata>
kprice9623e9d2007-05-03 03:43:05 +000015<keywords><indexterm>XML schema editor<indexterm>complex types</indexterm></indexterm>
16<indexterm>XML schema files<indexterm>complex types</indexterm></indexterm>
kprice159fa582006-05-08 21:30:45 +000017</keywords>
18</metadata></prolog>
19<taskbody>
20<context><p>You can add as many complex types as you want to an XML schema.</p><p>The
21following instructions were written for the Resource perspective, but they
22will also work in many other perspectives.</p><p>To add a complex type to
23an XML schema, follow these steps:</p></context>
24<steps>
25<step><cmd>Open your XML schema in the XML schema editor.</cmd></step>
kprice647b7352006-05-17 21:27:16 +000026<step><cmd>Right-click the Types category in the Design view, and click <uicontrol>Add
kprice159fa582006-05-08 21:30:45 +000027Complex Type</uicontrol>.</cmd></step>
28<step><cmd>In the Properties view, type a new name for the complex type in
29the <uicontrol>Name</uicontrol> field.</cmd></step>
kprice647b7352006-05-17 21:27:16 +000030<step><cmd>Click <uicontrol>Browse</uicontrol> <image href="../images/Browse.gif">
31<alt>Browse icon</alt></image> to select a base type for your complex type.</cmd>
32<info>You can either set a base type for your complex type, or you can add
33a content model to it (which represents any data that can be contained inside
34an element), but you cannot do both. For more information about content models,
35refer to the related tasks.</info></step>
kprice159fa582006-05-08 21:30:45 +000036<step><cmd>Select <uicontrol>restriction</uicontrol> or <uicontrol>extension</uicontrol> from
37the <uicontrol>Inherited by</uicontrol> list.</cmd><info>This specifies whether
38your type is derived from its base type by restriction or extension.</info>
39</step>
kprice647b7352006-05-17 21:27:16 +000040<step><cmd>The Design view will display the attributes within the complex
41type.</cmd><info>You can also use this view to add attributes to your complex
42type. An attribute associates an attribute name with a specific type and value.</info>
kprice159fa582006-05-08 21:30:45 +000043<choices>
kprice647b7352006-05-17 21:27:16 +000044<choice>To add an attribute, in the Design view, right click your complex
45type and select <uicontrol>Add Attribute</uicontrol>.<ul>
46<li><uicontrol>name</uicontrol>. In the Design view, click the name of the
47attribute to make a change.</li>
48<li><uicontrol>type</uicontrol>. In the Design view, click the type of the
49attribute to make a change. The drop-down menu provides commonly used types.
50For more options, simply select <uicontrol>Browse</uicontrol> from the menu.</li>
51</ul></choice>
kprice159fa582006-05-08 21:30:45 +000052</choices>
53</step>
54<step><cmd>An attribute reference provides a reference to a global attribute.
kprice647b7352006-05-17 21:27:16 +000055To add an attribute reference, in the Design view, right-click the complex
kprice159fa582006-05-08 21:30:45 +000056type containing the element, and click <uicontrol>Add Attribute Ref</uicontrol>.</cmd>
57<info>A declaration that references a global attribute enables the referenced
58attribute to appear in the instance document in the context of the referencing
kprice647b7352006-05-17 21:27:16 +000059declaration. Select the reference, then select the attribute group you want
60it to reference in the Properties view, from the<uicontrol> Ref</uicontrol> menu.</info>
kprice159fa582006-05-08 21:30:45 +000061</step>
62<step><cmd>An attribute group reference provides a reference to an attribute
kprice647b7352006-05-17 21:27:16 +000063group. To add an attribute group reference, in the Design view, right-click
kprice159fa582006-05-08 21:30:45 +000064the complex type containing the element, and click <uicontrol>Add Attribute
65Group Ref</uicontrol>.</cmd><info>A declaration that references an attribute
66group enables the referenced attribute group to appear in the instance document
kprice647b7352006-05-17 21:27:16 +000067in the context of the referencing declaration. Select the reference, then
68select the attribute group you want it to reference in the Properties view,
69from the<uicontrol> Ref</uicontrol> menu.</info></step>
kprice159fa582006-05-08 21:30:45 +000070<step><cmd>An <codeph>any</codeph> element enables element content according
71to namespaces, and the corresponding <codeph>any</codeph> attribute element
72enables attributes to appear in elements. To add an <codeph>any</codeph> attribute,
73right-click in the complex type header, and click <uicontrol>Add Any Attribute</uicontrol>.</cmd>
74<info>You can specify the following values for an <codeph>any</codeph> attribute:</info>
75<choices>
kprice9623e9d2007-05-03 03:43:05 +000076<choice>For a <uicontrol>namespace</uicontrol> value, you can
kprice647b7352006-05-17 21:27:16 +000077select:<ul>
78<li><b>##any</b>. This allows any well-formed XML from any namespace.</li>
79<li><b>##local </b>. This allows any well-formed XML that is not declared
80to be in a namespace.</li>
81<li><b>##other</b>. This allows any well-formed XML that is not from the target
82namespace of the type being defined.</li>
83<li><b>##targetNamespace </b>. This is shorthand for the target namespace
84of the type being defined.</li>
85</ul></choice>
86<choice>For a <uicontrol>processContents</uicontrol> value, you can select:<ul>
87<li><b>skip</b>. The XML processor will not validate the attribute content
88at all.</li>
89<li><b>lax</b>. The XML processor will validate the attribute content as much
90as it can.</li>
91<li><b>strict</b>. The XML processor will validate all the attribute content.</li>
92</ul></choice>
kprice159fa582006-05-08 21:30:45 +000093</choices>
94<info></info></step>
95<step><cmd>Click the <uicontrol>Documentation</uicontrol> tab if you want
96to provide any information about this complex type.</cmd><info>The <uicontrol>Documentation</uicontrol> page
kprice647b7352006-05-17 21:27:16 +000097is used for human readable material, such as a description.</info></step>
98<step><cmd>Click the <uicontrol>Extensions</uicontrol> tab if you want to
99add application information elements to your annotations of schema components.</cmd>
100<info>The <uicontrol>Extensions</uicontrol> page allows you to specify the
101schema and add XML content to your annotations.</info></step>
kprice159fa582006-05-08 21:30:45 +0000102</steps>
103</taskbody>
104</task>
kprice647b7352006-05-17 21:27:16 +0000105<?Pub *0000006207?>