example
example — A formal example, with a title.
Synopsis
example ::=
- Sequence of:
- One of:
- One or more of:
annotation
bridgehead
formalgroup
remark
revhistory
- Indexing inlines
- Admonition elements
- Formal elements
- Graphic elements
- Informal elements
informalequation
informalexample
informalfigure
informaltable
(db.cals.informaltable)informaltable
(db.html.informaltable)
- List elements
- Paragraph elements
- Publishing elements
- Synopsis elements
- Technical elements
- Verbatim elements
caption
? (db.caption)
Attributes
Common attributes and common linking attributes.
Additional attributes:
- floatstyle
- label
- type
- At most one of:
- width (nonNegativeInteger)
- pgwide (enumeration)
- “0”
- “1”
Additional Constraints
- example must not occur among the children or descendants of example
- figure must not occur among the children or descendants of example
- table must not occur among the children or descendants of example
- equation must not occur among the children or descendants of example
- If this element is the root element, it must have a version attribute.
Description
An example
is a formal example with a title. Examples
often contain programlisting
s or other
large block
elements. Frequently, they are given xml:id
s 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.
If a label
is specified, that label
will be used for identifying the example and in generated
cross-references. If unspecified, example
s are often, but
not always, numbered.
If a width
is specified, formatters
may use this value to determine scaling or rotation.
Attributes
Common attributes and common linking attributes.
- any attribute
Any attribute in any other explicit namespace
- floatstyle
Specifies style information to be used when rendering the float
- label
Specifies an identifying string for presentation purposes
- pgwide
Indicates if the element is rendered across the column or the page
Enumerated values: “0” The element should be rendered in the current text flow (with the flow column width).
“1” The element should be rendered across the full text page.
- type
Identifies the type of example
- width
Specifies the width (in characters) of the element
Parents
These elements contain example
: abstract
, acknowledgements
, annotation
, answer
, appendix
, article
, bibliodiv
, bibliography
, bibliolist
, blockquote
, callout
, calloutlist
, caption
(db.caption), caution
, chapter
, colophon
, constraintdef
, danger
, dedication
, entry
, example
, figure
, footnote
, formalgroup
, glossary
, glossdef
, glossdiv
, glosslist
, important
, index
, indexdiv
, informalexample
, informalfigure
, itemizedlist
, legalnotice
, listitem
, meta
(db.meta.content), msgexplan
, msgtext
, note
, orderedlist
, para
, partintro
, preface
, procedure
, qandadiv
, qandaset
, question
, refsect1
, refsect2
, refsect3
, refsection
, refsynopsisdiv
, result
, revdescription
, sect1
, sect2
, sect3
, sect4
, sect5
, section
, setindex
, sidebar
, simplesect
, step
, task
, taskprerequisites
, taskrelated
, tasksummary
, td
, textobject
, th
, tip
, toc
, tocdiv
, topic
, variablelist
, warning
.
Children
The following elements occur in example
: address
, anchor
, annotation
, bibliolist
, blockquote
, bridgehead
, calloutlist
, caption
(db.caption), caution
, classsynopsis
, cmdsynopsis
, constraintdef
, constructorsynopsis
, danger
, destructorsynopsis
, enumsynopsis
, epigraph
, equation
, example
, fieldsynopsis
, figure
, formalgroup
, formalpara
, funcsynopsis
, glosslist
, important
, indexterm
(db.indexterm.endofrange), indexterm
(db.indexterm.singular), indexterm
(db.indexterm.startofrange), info
(db.titleforbidden.info), info
(db.titleonlyreq.info), informalequation
, informalexample
, informalfigure
, informaltable
(db.cals.informaltable), informaltable
(db.html.informaltable), itemizedlist
, literallayout
, macrosynopsis
, mediaobject
, methodsynopsis
, msgset
, note
, orderedlist
, packagesynopsis
, para
, procedure
, productionset
, programlisting
, programlistingco
, qandaset
, remark
, revhistory
, screen
, screenco
, screenshot
, segmentedlist
, sidebar
, simpara
, simplelist
, synopsis
, table
(db.cals.table), table
(db.html.table), task
, tip
, title
, titleabbrev
, typedefsynopsis
, unionsynopsis
, variablelist
, warning
.
See Also
Related elements: equation
, figure
, informalequation
, informalexample
, informalfigure
, informaltable
, table
.
Examples
1 |<article xmlns='http://docbook.org/ns/docbook'>
|<title>Example example</title>
||
<example xml:id="ex.dssslfunction">
5 |<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
10 |(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))
15 |(node-list-rest nl))
|(loop result (node-list-rest nl))))))
|</programlisting>
|</example>
|20 |
</article>
1 ||
(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
5 |(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))
10 |(node-list-rest nl))
|(loop result (node-list-rest nl))))))