Understanding XML DTDs

 < Day Day Up > 



Because DTD conformance is important for Struts tags, a brief overview of how XML DTDs work is given here. DTDs specify a set of tags and attributes that make up a specific XML document type. DTDs also specify the order in which tags must be placed in the file, and the relationship between tags. For example, a tag definition defines what other tags can be nested inside of it, how many occurrences can be nested, and in what order the nesting can occur. Additionally, DTDs define which tag attributes are required and which are optional.

Each tag described in this chapter has a DTD Definition section that lists the tag’s definition in the Struts configuration file DTD. The definitions will be similar to the one shown in the following snippet:

<!ELEMENT form-bean (icon?, display-name?, description?, set-property*, form- property*)>

This example defines a form-bean tag and the tags that can be nested inside of it. According to the definition, the tag can have nested icon, display-name, description, set-property, and form-property tags. The question mark (?) and asterisk (*) characters following the nested tags’ names indicate the number of times the nested tag can be nested. The question mark character indicates that the tag can be nested zero or one time. The asterisk character indicates that the tag can be nested zero or more (unlimited) times. A plus (+) character indicates that the tag must be nested at least once and as many times as you’d like. The lack of a trailing character means that the tag must be nested exactly once and no more. If no tags can be nested inside the defined tag, EMPTY will be used to denote that:

<!ELEMENT set-property EMPTY>



 < Day Day Up > 



Struts. The Complete Reference
Struts: The Complete Reference, 2nd Edition
ISBN: 0072263865
EAN: 2147483647
Year: 2003
Pages: 134
Authors: James Holmes

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net