blob: adfb02e0755e493783e5c9a53b9d29163a611b3e [file] [log] [blame]
kprice159fa582006-05-08 21:30:45 +00001<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2<html lang="en-us" xml:lang="en-us">
syeshinf3d0d4b2005-07-27 18:33:03 +00003<head>
kprice159fa582006-05-08 21:30:45 +00004<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
kpricede20a692008-04-24 00:27:47 +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 http://www.eclipse.org/legal/epl-v10.html. Contributors: IBM Corporation - initial API and implementation" />
6<meta name="DC.rights.owner" content="(C) Copyright 2000, 2008" />
kprice159fa582006-05-08 21:30:45 +00007<meta content="public" name="security" />
8<meta content="index,follow" name="Robots" />
9<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
10<meta content="task" name="DC.Type" />
11<meta name="DC.Title" content="Adding content models" />
12<meta name="abstract" content="A content model is the representation of any data that can be contained inside an element, global element, complex type, or group. It is a formal description of the structure and permissible content of an element, global element, complex type, or group, which may be used to validate a document instance." />
13<meta name="description" content="A content model is the representation of any data that can be contained inside an element, global element, complex type, or group. It is a formal description of the structure and permissible content of an element, global element, complex type, or group, which may be used to validate a document instance." />
kpricede20a692008-04-24 00:27:47 +000014<meta content="XML schema editor, content models, XML schema files" name="DC.subject" />
15<meta content="XML schema editor, content models, XML schema files" name="keywords" />
kprice43d0c0f2006-05-18 15:56:09 +000016<meta scheme="URI" name="DC.Relation" content="../topics/taddanye.html" />
17<meta scheme="URI" name="DC.Relation" content="../topics/taddelm.html" />
18<meta scheme="URI" name="DC.Relation" content="../topics/taddelmr.html" />
19<meta scheme="URI" name="DC.Relation" content="../topics/taddgrpr.html" />
kprice159fa582006-05-08 21:30:45 +000020<meta content="XHTML" name="DC.Format" />
21<meta content="taddcmod" name="DC.Identifier" />
22<meta content="en-us" name="DC.Language" />
23<link href="../../org.eclipse.wst.doc.user/common.css" type="text/css" rel="stylesheet" />
24<title>Adding content models</title>
syeshin8f077832005-09-06 04:22:45 +000025</head>
syeshinf3d0d4b2005-07-27 18:33:03 +000026<body id="taddcmod"><a name="taddcmod"><!-- --></a>
27
kprice159fa582006-05-08 21:30:45 +000028
syeshind0bdb8e2005-10-27 17:44:14 +000029<h1 class="topictitle1">Adding content models</h1>
kprice159fa582006-05-08 21:30:45 +000030
31
32
33
syeshind0bdb8e2005-10-27 17:44:14 +000034<div><p>A content model is the representation of any data that can be contained
35inside an element, global element, complex type, or group. It is a formal
36description of the structure and permissible content of an element, global
37element, complex type, or group, which may be used to validate a document
38instance.</p>
kprice159fa582006-05-08 21:30:45 +000039
40<div class="section"><div class="p">There are three different kinds of content models:<ul>
41<li><strong>Sequence</strong>, which means that all the content model's children can
syeshinf3d0d4b2005-07-27 18:33:03 +000042appear in an instance of the XML schema. They must, however, appear in the
43order they are listed in the content model.</li>
kprice159fa582006-05-08 21:30:45 +000044
45<li><strong>Choice</strong>, which means that only one of the content model's children
syeshinf3d0d4b2005-07-27 18:33:03 +000046can appear in an instance of the XML schema.</li>
kprice159fa582006-05-08 21:30:45 +000047
48<li><strong>All</strong>, which means that all of the content model's children can appear
49once or not at all, and they can appear in any order. If you select this option,
syeshinf3d0d4b2005-07-27 18:33:03 +000050all of the contents model's children must be individual elements and no element
kprice159fa582006-05-08 21:30:45 +000051in the content model can appear more than once.</li>
52
syeshinf3d0d4b2005-07-27 18:33:03 +000053</ul>
54</div>
kprice159fa582006-05-08 21:30:45 +000055<p>The following instructions were written for the Resource perspective,
56but they will also work in many other perspectives.</p>
syeshinf3d0d4b2005-07-27 18:33:03 +000057<p>To add a content
kpricede20a692008-04-24 00:27:47 +000058model to an element, global element, complex type, or group, complete the
59following steps:</p>
syeshinf3d0d4b2005-07-27 18:33:03 +000060</div>
kprice159fa582006-05-08 21:30:45 +000061
62<ol>
kprice43d0c0f2006-05-18 15:56:09 +000063<li class="stepexpand"><span>In the Design view, select your complex type, or group:</span>
kprice159fa582006-05-08 21:30:45 +000064<ul>
65<li>If you selected a complex type, you can right-click it and click <span class="uicontrol">Add
66Sequence</span>, or <span class="uicontrol">Add Choice</span> to add the type
67of content model you want to your complex type. If you wish to use the <span class="uicontrol">all</span> content
kprice43d0c0f2006-05-18 15:56:09 +000068model, you can change the model by clicking the model in the Design view,
69and in properties, select <span class="uicontrol">all</span> as the <span class="uicontrol">Kind</span>.
kprice159fa582006-05-08 21:30:45 +000070Your content model is automatically added as a child of your complex type
71- expand in the Outline view to see it. <strong>Note:</strong> These options will not
72appear if you have set a base type for your complex type. You can either set
73a base type for your complex type, or you add a content model to it, but you
74cannot do both.</li>
75
syeshinf3d0d4b2005-07-27 18:33:03 +000076<li>Your group is automatically created with a sequence content model
77child. Expand it in the Outline view to see it and select it. In the Properties
kprice159fa582006-05-08 21:30:45 +000078view, you can select to change it to a <span class="uicontrol">choice</span> or <span class="uicontrol">all</span> content
kpricede20a692008-04-24 00:27:47 +000079model by selecting these options from the <span class="uicontrol">Kind</span> drop-down.</li>
kprice159fa582006-05-08 21:30:45 +000080
syeshinf3d0d4b2005-07-27 18:33:03 +000081</ul>
kprice159fa582006-05-08 21:30:45 +000082
syeshinf3d0d4b2005-07-27 18:33:03 +000083</li>
kprice159fa582006-05-08 21:30:45 +000084
kpricede20a692008-04-24 00:27:47 +000085<li class="stepexpand"><strong>Optional: </strong><span>Select the appropriate value in the <span class="uicontrol">Minimum
86Occurrence</span> field.</span> This is the minimum
87number of times the content model must appear. If you want the content model
88to be optional, select <span class="uicontrol">0</span>. Otherwise, select <span class="uicontrol">1</span>.
89</li>
kprice159fa582006-05-08 21:30:45 +000090
kpricede20a692008-04-24 00:27:47 +000091<li class="stepexpand"><strong>Optional: </strong><span>Select the appropriate value in the <span class="uicontrol">Maximum
92Occurrence</span> field.</span> This is the maximum number of times
93a content model can appear. You can select <span class="uicontrol">unbounded</span> to
94indicate there is no maximum number of occurrences.</li>
kprice159fa582006-05-08 21:30:45 +000095
96<li class="stepexpand"><span>Click the <span class="uicontrol">Documentation</span> tab if you want
syeshinf3d0d4b2005-07-27 18:33:03 +000097to provide any information about this content model.</span> The <span class="uicontrol">Documentation</span> page
kpricede20a692008-04-24 00:27:47 +000098is used for human readable material, such as a description.</li>
kprice159fa582006-05-08 21:30:45 +000099
kprice43d0c0f2006-05-18 15:56:09 +0000100<li class="stepexpand"><span>Click the <span class="uicontrol">Extensions</span> tab if you want to
101add application information elements to your annotations of schema components.</span>
102 The <span class="uicontrol">Extensions</span> page allows you to specify the
103schema and add XML content to your annotations.</li>
104
syeshinf3d0d4b2005-07-27 18:33:03 +0000105</ol>
kprice159fa582006-05-08 21:30:45 +0000106
kpricede20a692008-04-24 00:27:47 +0000107<div class="section"><p>You can add the following items to a content object model: </p>
kprice159fa582006-05-08 21:30:45 +0000108<ul>
109<li>Another content model.</li>
110
syeshinf3d0d4b2005-07-27 18:33:03 +0000111<li>A group reference which enables the referenced group to appear in the
kprice159fa582006-05-08 21:30:45 +0000112instance document in the context of the referencing declaration. This menu
113option only appears if there are global groups defined elsewhere in the document
114or if groups are defined in included schemas.</li>
115
syeshinf3d0d4b2005-07-27 18:33:03 +0000116<li>An element, fundamental building blocks in XML.</li>
kprice159fa582006-05-08 21:30:45 +0000117
syeshinf3d0d4b2005-07-27 18:33:03 +0000118<li>An element reference, which provides a reference to a global element.
119This menu option only appears if there are global elements defined elsewhere
120in the document.</li>
kprice159fa582006-05-08 21:30:45 +0000121
syeshinf3d0d4b2005-07-27 18:33:03 +0000122<li>An <samp class="codeph">any</samp> element. You can use an <samp class="codeph">any</samp> element
123to extend your content model by any elements belonging to a specified namespace.</li>
kprice159fa582006-05-08 21:30:45 +0000124
syeshinf3d0d4b2005-07-27 18:33:03 +0000125</ul>
126</div>
kprice159fa582006-05-08 21:30:45 +0000127
syeshinf3d0d4b2005-07-27 18:33:03 +0000128</div>
kprice159fa582006-05-08 21:30:45 +0000129
kprice43d0c0f2006-05-18 15:56:09 +0000130<div><div class="reltasks"><strong>Related tasks</strong><br />
131<div><a href="../topics/taddanye.html" title="You can use the any element in a similar way as a DTD's ANY content model, however, it must be done in conjunction with namespaces. This enables you to include any well-formed XML content, such as an HTML Web page that conforms to XHTML 1.0 syntax.">Adding an any element</a></div>
132<div><a href="../topics/taddelm.html" title="Elements are fundamental building blocks in XML. Element declarations provide value constraints, provide a description that can be used for validation, establish constraining relationships between related elements and attributes, and control the substitution of elements.">Adding elements</a></div>
133<div><a href="../topics/taddelmr.html" title="An element reference provides a reference to a global element. A declaration that references a global element enables the referenced global element to appear in the instance document in the context of the referencing declaration.">Adding element references</a></div>
134<div><a href="../topics/taddgrpr.html" title="A group reference is a declaration that references a group. It enables the referenced group to appear in the instance document in the context of the referencing declaration.">Adding group references</a></div>
135</div>
136</div>
kprice159fa582006-05-08 21:30:45 +0000137
138</body>
syeshinf3d0d4b2005-07-27 18:33:03 +0000139</html>