|
To access the contents, click the chapter and section titles.
Platinum Edition Using HTML 4, XML, and Java 1.2
Element SequencesThe simplest form of element content model is a sequence consisting of a list of the possible elements, enclosed in parentheses and separated by commas: <!ELEMENT counting (first,second,third,fourth)> This example means that a counting element must consist of a first element, followed by a second element, followed by a third element, and ending with a fourth element. In this example, all four elements must be present in a counting element, and each may be present only once (you can specify how often an element may appear by using an occurrence indicator, which you will learn about later in this chapter). An element model with a sequence such as this would be used whenever you have an element that must be made up of a specific number of parts, which must occur in a specific order, and all of which must be present. For instance, you could create a business.letter element defined as follows: <!ELEMENT business.letter (date,address,greeting,body,salutation)> A sequence such as this could also be used to count up the chapters in a book; however, remember that all the elements in the sequence must appear. Therefore, this will only work if you know precisely how many chapters you wish to use. ChoicesA choice of elements in an element content model is indicated by a | between the alternatives: <!ELEMENT choose (this.one | that.one)> so that a choose element consists of either a this.one element or a that.one element. Notice once again that without an occurrence indicator, the chosen element can appear only once. Note also that only one element can be selected, no matter how long the list of alternatives is: <!ELEMENT choose (this.one | that.one | the.other.one | another.one | no.that.one.silly)> The choice element content model works best when a number of choices are available, one and only one of which must be selected. A correspondence element, for example, might include a number of choices to describe the type of correspondence: <!ELEMENT correspondence (business.letter | personal.letter | quick.note)> Combined Sequences and ChoicesYou can combine content sequence and choices by grouping the element content into model groups. For example: <!ELEMENT lots.of.choice (maybe | could.be), (this.one, that.one)> Here, a lots.of.choice element can consist of either a maybe element or a could.be element, followed by one this.one element and then one that.one element. This type of combination model could be used for address data, for instance: <!ELEMENT return.address (business.name | personal.name),(street.address,city,state,zip)> In this example, the address can belong to either a business or a person, and then must include a street address, city, state, and zip code.
Occurrence IndicatorsUsing an occurrence indicator, you can specify how often (or not) an element or group of elements may appear in an element. Three occurrence indicators exist (without an occurrence indicator, the element or group of elements must appear only once):
|
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement. |