extensibility

Creating a Content Model for an Element


XML Authority provides two helpful tools to facilitate the process of building a Content Model for an element.  The first, XML Authority's content model Qlicker (Figure A), provides an easily accessed menu with choices to help build a content model in the Element List pane of the Element Types pane.  The second, the Content Model editor (Figure I), includes the Qlicker buttons, but gives the user much more space in which to work while editing a content model.

Building a Content Model with the Qlicker

The steps involved with building a content model are relatively straightforward, especially if XML Authority's Qlicker is used in the process (Figure A).

editing a content model

Figure A- Content Model Qlicker

For example, let's build a content model for an element based on the structure of a book (element name: Book).  Book's content model would most likely include several items, including a Title, an Author, multiple Chapters, maybe an Appendix (or several), perhaps a Glossary, and possibly an Index.   Assuming these elements are already declared, the steps to build the content model for Book appear below:

1.  In element type Book's row, click on the blank cell under the Content Model column.  This is where the entry for the content model will be created.   The Qlicker appears, as shown in Figure B.

  blankcm.jpg (12749 bytes)

Figure B - Blank Content Model with Qlicker

2.  Click the Insert button on the Qlicker.  A pull-down menu of all the element type declarations within the file appears (Figure C).

insertpulldown.jpg (29633 bytes)

Figure C - The Insert pull-down menu

3.  Select the first element to be part of the content model (in this case, we'll start with Title).  Repeat this step, selecting each element that is part of the content model.  It's best to select the sub-elements in sequence if possible, because as each sub-element is selected, a comma is inserted between each by default (which indicates that the items are in sequence).  The sub-element will always be inserted where the cursor is placed in the content model.  After selecting all the sub-elements, the content model will look like Figure D below.

samplecm1.jpg (17987 bytes)

Figure D - Selection of Sub-Elements in Sequence

4.  Which items may be repeatable?  Within a book, the chapters usually occur more than once, so this sub-element needs to be indicated as a repeatable item.   Highlight Chapter in the Content Model, and click on the Repeatable button.  This adds a '+' indicator after Chapter, to indicate it is repeatable.  Likewise, there may be more than one appendix, so highlight Appendix and click Repeatable to add a '+' indicator after Appendix (Figure E).

samplecm2.jpg (19294 bytes)

Figure E - Select Appendix and click Repeatable to add a '+'

5.  Which items are optional?  Within a book, a glossary or index may not always occur, so these sub-elements need to be made optional.  Highlight Glossary, and click the Optional button.  Likewise, highlight Index, and click the Optional button (Figure F).  This will place a '?' after each of these sub-elements, to indicate they are optional.

samplecm3.jpg (19372 bytes)

Figure F - Select Index and click Optional to add a '?'

Appendix is also an optional item (not all books have appendices).   Highlight Appendix and click the Optional button.  Because Appendix is now both optional and repeatable, it is indicated with an '*' after it.  Press the <Enter> key or click anywhere else in the Element Type pane to enter the Content Model into its cell.  The completed content model is displayed in Figure G.  The graphic depiction of the content model, which appears in the Content Model pane of the Element Types pane, is shown in Figure H.

samplecm4.jpg (10015 bytes)

Figure G - Completed content model

 

samplecm5.jpg (25116 bytes)

Figure H - Graphic depiction of content model

The two other Qlicker buttons not used in the above example are the Parentheses button [( )], which groups selected sub-elements together in parentheses, and the Choices button, which indicates choices between several sub-elements (sub-elements are separated by an '|' indicator).

For those individuals comfortable with occurrence indicators and sequence indicators, a content model (or parts of it) can be typed in manually, if desired.

Building a Content Model with the Content Model Editor

Content models can become quite complex, and for this reason, XML Authority has provided the Content Model editor (Figure I) to help the user create a Content Model.   The editor includes the Qlicker, and its buttons are used the same way as in the above example, with only one exception.  No Insert button is available within the editor's Qlicker.  However, a list of declared elements and reusables are listed on the left side of the pane.

cmeditor.jpg (49395 bytes)

Figure I - Content Model editor

The main advantage to the Content Model editor is space -- users are given an entire pane within which they can enter their content model.  To access the Content Model editor, from within the Element Type pane select the area under the Content Model column for the appropriate element type's row, then choose the View menu option, then Expand.  When finished editing/creating the content model, close the Content Model editor window by clicking on the Save button within the window.   As mentioned previously, the user may also type in a content model (or parts of it) manually within the Content Model editor.

Copyright 2000 Extensibility, Inc.

Suite 250, 200 Franklin Street, Chapel Hill, North Carolina 27516