When defining documents, you can add attributes, which will be added to the base environment when applying level functions to this document. For example:

.... ....
]]>

Here the node <author/> will we rewritten to "Santa Claus" (without quotes).

The same can be achieved for more complex nodes, using the with-contents="true" attribute:

Santa Claus .... .... ]]>

here <author/> will we rewritten to <b>Santa Claus</b>.

You can also define functions. A function is defined like an attribute when having with-contents="true", except the node defining the name of the function has XML attributes:

...
 
... .... ls -l ]]>

Here we define a function <command> which allows to put some XML into a

 node, with a prompt before.
<contents/> is used to insert the "contents" parameter of the function,
that is the subnodes of the <command> node.

So ls -l will be rewritten to ls -l.

prompt is an argument for , with a default value set to "# ". This argument can be changed when "calling" the function:

... select * from table ...

will be rewritten to

... select * from table ...

Even attributes of the <command/> nodes which are not "declared" in the rule attribute list are added to the environment used when applying the <command> rule.

It is not unusual to declare only one dummy parameter to create a function so that <contents/> can be used in the rule body, this way:

... ... ... bla bla ... ]]>

To define functions available for all documents, you have to define them in the main document and prefix their name with "stog:", like "stog:command". Then, the <command> rule will be available in all documents; besides it can be redefined in a document to change this rule for this document only.