next up previous
Next: Attribute declarations
Up: The WOM language
Previous: Sessions and applications

The class element; detached instances

 

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.



Jocelyn Ireson-Paine
Fri May 30 14:03:06 BST 1997