|
To access the contents, click the chapter and section titles.
Platinum Edition Using HTML 4, XML, and Java 1.2
Using occurrence indicators, we could generalize our return.address element as follows: <!ELEMENT return.address ((business.name,attn?) | personal.name*),(street.address+,city,state,zip)> This element breaks down as follows:
Character ContentOne more type of element content is a little bit different from what we have discussed so far. Where textand only textis allowed inside an element, this is identified by the keyword PCDATA in the content model (parsable character data). To prevent you from confusing this keyword with a normal element name (and to make it impossible for you to use it as a name), the keyword is prefixed by a hash character (#), which is called the reserved name character (RNI). The following element declarations: <!ELEMENT para (title, text)> <!ELEMENT title (#PCDATA)> <!ELEMENT text (#PCDATA)> would enable you to write this in your XML document: <para> <title>My Life</title> <text> My life has been very quiet of late. </text> </para> A parsable character data element that cannot contain any further markup is therefore where the markup stops and normal text takes over.
Mixed ContentElements that can contain either text (parsable character data), elements, or both are a real problem sometimes. They are given the name mixed content models, and they require extra care. The important point is that it is difficult for an XML processor to distinguish between unintentional PCDATA (spaces, tabs, line endings, and so on) and element content. An accidental space between an end tag and the next start tag could lead to some confusion on the part of the XML processor. To declare mixed content, you use the content model grammar you have learned so far, but you must use it in a particular way. The content model has to take the form of a single set of alternatives, starting with #PCDATA and followed by the element types that can occur in the mixed content, each declared only once. Except when #PCDATA is the only option (as you saw earlier), the * qualifier must follow the closing parenthesis: <!ELEMENT pick (#PCDATA | eeney | meeney | miney | mo)*> Attribute DeclarationsAlthough you can declare only one element at a time, elements can have lots of attributes, and so the attributes are all declared at once in an attribute specification list. An attribute declaration has the form <!ATTLIST element.name attribute.definitions> It is normal practice to keep the attribute declaration for an element close to the declaration of the element itself, but there is absolutely no requirement to do so; it just makes maintenance easier. Attribute Specification ListsAn attribute specification list consists of one or more attribute specifications (for readability they are often put on separate lines, but this is not required). An attribute specification list does the following for an element:
Each attribute specification consists of a simple attribute name and attribute type pair statement of the form attribute.name attribute.type Attribute TypesThree types of attributes exist:
String Types The values of string types are simple strings of characters. Any attributes used in an XML document that does not have a DTD (either an internal DTD subset or an external DTD subset) is automatically treated as a string type attribute. An example of a string type declaration is <!ATTLIST owner CDATA> and you would then use it like this: <book owner=Hammersmith Public Library> You can also use an internal entity (in this case its given the more generic name general entity) in the value of a string type attribute: <book owner=&my.local; Public Library>
|
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. |