Example

Name

Example -- A formal example, with a title

Synopsis

Content Model

Example ::=
((Title,TitleAbbrev?),
 (CalloutList|GlossList|ItemizedList|OrderedList|SegmentedList|
  SimpleList|VariableList|LiteralLayout|ProgramListing|
  ProgramListingCO|Screen|ScreenCO|ScreenShot|Synopsis|
  CmdSynopsis|FuncSynopsis|FormalPara|Para|SimPara|Address|
  BlockQuote|Graphic|GraphicCO|MediaObject|MediaObjectCO|
  InformalEquation|InformalExample|InformalFigure|InformalTable|
  IndexTerm)+)

Attributes

Common attributes

Name

Type

Default

WidthNUMBERNone
LabelCDATANone

Tag Minimization

Both the start- and end-tags are required for this element.

Parameter Entities

%admon.mix;%bookcomponent.content;%component.mix;
%divcomponent.mix;%footnote.exclusion;%formal.class;
%formal.exclusion;%glossdef.mix;%highlights.exclusion;
%para.mix;%qandaset.mix;%refcomponent.mix;
%sidebar.mix;%tbl.table.excep;

Description

Example is a formal example with a title. Examples often contain ProgramListings or other large, block elements. Frequently they are given IDs and referenced from the text with XRef or Link.

Processing expectations

Formatted as a displayed block. DocBook does not specify the location of the example within the final displayed flow of text; it may float or remain where it is located.

A list of examples may be generated at the beginning of a document.

Parents

These elements contain Example: Answer, Appendix, Article, BiblioDiv, Bibliography, BlockQuote, Callout, Caution, Chapter, Glossary, GlossDef, GlossDiv, Important, Index, ListItem, MsgExplan, MsgText, Note, Para, PartIntro, Preface, Procedure, QandADiv, QandASet, Question, RefSect1, RefSect2, RefSect3, RefSynopsisDiv, Sect1, Sect2, Sect3, Sect4, Sect5, Section, SetIndex, Sidebar, SimpleSect, Step, Tip, Warning.

Children

The following elements occur in Example: Address, BlockQuote, CalloutList, CmdSynopsis, FormalPara, FuncSynopsis, GlossList, Graphic, GraphicCO, IndexTerm, InformalEquation, InformalExample, InformalFigure, InformalTable, ItemizedList, LiteralLayout, MediaObject, MediaObjectCO, OrderedList, Para, ProgramListing, ProgramListingCO, Screen, ScreenCO, ScreenShot, SegmentedList, SimPara, SimpleList, Synopsis, Title, TitleAbbrev, VariableList.

In some contexts, the following elements are allowed anywhere: BeginPage, IndexTerm.

In some contexts, the following elements are excluded: IndexTerm, InformalTable.

Attributes

Label

Label specifies an identifying string for presentation purposes.

Generally, an explicit Label attribute is used only if the processing system is incapable of generating the label automatically. If present, the Label is normative; it will used even if the processing system is capable of automatic labelling.

Width

Width specifies the width (in characters) of the longest line in this Example (formatters may use this value to determine scaling or rotation).

See Also

Equation, Figure, InformalEquation, InformalExample, InformalFigure, InformalTable, Table

Examples

<!DOCTYPE example PUBLIC "-//OASIS//DTD DocBook V3.1//EN">
<example><title>A DSSSL Function</title>
<programlisting>
(define (node-list-filter-by-gi nodelist gilist)
  ;; Returns the node-list that contains every element of the original
  ;; nodelist whose gi is in gilist
  (let loop ((result (empty-node-list)) (nl nodelist))
    (if (node-list-empty? nl)
	result
	(if (member (gi (node-list-first nl)) gilist)
	    (loop (node-list result (node-list-first nl)) 
		  (node-list-rest nl))
	    (loop result (node-list-rest nl))))))
</programlisting>
</example>

Example 1. A DSSSL Function

(define (node-list-filter-by-gi nodelist gilist)
  ;; Returns the node-list that contains every element of the original
  ;; nodelist whose gi is in gilist
  (let loop ((result (empty-node-list)) (nl nodelist))
    (if (node-list-empty? nl)
	result
	(if (member (gi (node-list-first nl)) gilist)
	    (loop (node-list result (node-list-first nl)) 
		  (node-list-rest nl))
	    (loop result (node-list-rest nl))))))

For additional examples, see also Comment.

Copyright © 1999 O'Reilly & Associates, Inc. All rights reserved.