| <?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"> |
| <html> |
| <head> |
| <!-- /******************************************************************************* |
| * Copyright (c) 2000, 2005 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 |
| *******************************************************************************/ --> |
| <link rel="stylesheet" type="text/css" href="../../org.eclipse.wst.doc.user/common.css" /> |
| <title>Adding a content model</title> |
| </head> |
| <body id="taddcmod"><a name="taddcmod"><!-- --></a> |
| |
| <h1 class="topictitle1">Adding content models</h1> |
| <div><p>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.</p> |
| <div class="section"><div class="p">There are three different kinds of content models:<ul><li><strong>Sequence</strong>, which means that all the content model's children can |
| appear in an instance of the XML schema. They must, however, appear in the |
| order they are listed in the content model.</li> |
| <li><b>Choice</b>, which means that only one of the content model's children |
| can appear in an instance of the XML schema.</li> |
| <li><b>All</b>, which means that all of the content model's children can appear |
| once or not at all, and they may appear in any order. If you select this option, |
| all of the contents model's children must be individual elements and no element |
| in the content model may appear more than once</li> |
| </ul> |
| </div> |
| <p>The following instructions were written for the Resource perspective, but |
| they will also work in many other perspectives.</p> |
| <p>To add a content |
| model to an element, global element, complex type, or group, follow these |
| steps:</p> |
| </div> |
| <ol><li class="stepexpand"><span>In the Outline view, select your element, global element, complex |
| type, or group:</span><ul><li>If you selected an element or global element, you can right-click |
| it, and click <span class="uicontrol">Add Sequence</span>, <span class="uicontrol">Add Choice</span>, |
| or <b> <span class="uicontrol">Add All</span></b> to add the type of content model you want |
| to your element or global element. Your content model is automatically added |
| as a child of a local complex type - expand your element or global element |
| in the Outline view to see it.</li> |
| <li>If you selected a complex type, you can right-click it and click <b> <span class="uicontrol">Add |
| Sequence</span></b>, <b> <span class="uicontrol">Add Choice</span></b>, or <b> <span class="uicontrol">Add |
| All</span></b> to add the type of content model you want to your complex |
| type. Your content model is automatically added as a child of your complex |
| type - expand in the Outline view to see it. <b>Note: </b>These |
| options will not appear if you have set a base type for your complex type. |
| You can either set a base type for your complex type, or you add a content |
| model to it, but you cannot do both.</li> |
| <li>Your group is automatically created with a sequence content model |
| child. Expand it in the Outline view to see it and select it. In the Properties |
| view, you can select to change it to a <b> <span class="uicontrol">choice</span></b> or |
| <b> <span class="uicontrol">all</span></b> content |
| model by selecting these options from the <b> <span class="uicontrol">Kind</span></b> drop |
| down list.</li> |
| </ul> |
| </li> |
| <li class="skipspace"><span>(Optional) Select the appropriate value in the <b> <span class="uicontrol">MinOccurs</span></b> field.</span> This is the number of times the content model must appear. If you want |
| the content model to be optional, select <b> <span class="uicontrol">0</span></b>. Otherwise, |
| select <b> <span class="uicontrol">1</span></b>. </li> |
| <li class="skipspace"><span>(Optional) Select the appropriate value in the <b> <span class="uicontrol">MaxOccurs</span></b> field.</span> This is the maximum number of times a content model may appear. You |
| can select <span class="uicontrol">unbounded</span> to indicate there is no maximum |
| number of occurrences.</li> |
| <li class="skipspace"><span>Click the <b> <span class="uicontrol">Documentation</span></b> tab if you want |
| to provide any information about this content model.</span> The <span class="uicontrol">Documentation</span> page |
| is used for human readable material, such as a description, and the <span class="uicontrol">App |
| Info</span> page can be used to provide information for applications.</li> |
| </ol> |
| <div class="skipspace"><p>You can add the following to a content object model. </p> |
| <ul><li>Another content model.</li> |
| <li>A group reference which enables the referenced group to appear in the |
| instance document in the context of the referencing declaration. This |
| menu option only appears if there are global groups defined elsewhere in the |
| document or if groups are defined in included schemas.</li> |
| <li>An element, fundamental building blocks in XML.</li> |
| <li>An element reference, which provides a reference to a global element. |
| This menu option only appears if there are global elements defined elsewhere |
| in the document.</li> |
| <li>An <samp class="codeph">any</samp> element. You can use an <samp class="codeph">any</samp> element |
| to extend your content model by any elements belonging to a specified namespace.</li> |
| </ul> |
| </div> |
| </div> |
| <div><div class="reltasks"><strong>Related tasks</strong><br /> |
| <div><a href="../topics/taddanye.html" title="You can use the any element to provide something similar to 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> |
| <div><a href="../topics/taddelm.html" title="Elements are fundamental building blocks in XML. Element declarations provide value constraints, and a description that can be used for validation, as well as establishing constraining relationships between related elements and attributes, and controlling substitution of elements.">Adding elements</a></div> |
| <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> |
| <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> |
| </div> |
| </div></body> |
| </html> |