WOM will compile the example above into a definition for class
Top
, as directed by the <Class Top>
element. Were this
element omitted, WOM would assume the generated class to have the
same name as the source file, and would make it a subclass of
Page
. Thus <Class>
lets us specify its name and parent.
In general, if a
file does not start with the <Class>
element, the compiler will
translate it to a class with the same name as the file. Thus if the
first example above were in Fact.wom
, it would be converted to
a class definition for Fact
. This convention makes it easy to
use WOM for creating simple stand-alone dynamic pages.
If a <Class>
element is used, its first argument gives the
name of the class, overriding that inferred from the filename. The
second argument is optional, and if provided, specifies the class's
superclass.
When an instance of the class above, Top
, is created, it will
create one instance each of Fact
, Count
, Menus
and
Conditionals
, as instructed by the <Instance>
elements.
These create what I call ``detached instances''. Normally, when
instances are created inside a page, they are embedded in a fixed
position inside the page's contents list, and their HTML is emitted at
that point. However, that is not necessary here, since each instance is
a page in its own right and we never want more than one to be emitted at
the same time.