OmniMark is a streaming language and its parsers do not build a parse tree in memory. Instead, OmniMark provides powerful query facilities for retrieving information about the context of the markup currently parsed.
current elements shelf represents the stack of currently open elements. This allows you to make
complex queries about all open elements. You can iterate over all open elements using
repeat over current
elements, inquire about the current element depth with
number of current elements or access
any particular element by its item number. The shelf is not keyed nor directly
modifiable by the user.
OmniMark also provides means to quickly access a particular element from the
shelf and to navigate through it.
The element qualifiers listed above can be combined to form more sophisticated queries. For example, the
parent of ancestor "row" is "thead"tests whether there is an element in
current elementsother than the
row, and whether the item preceding it in
current elementsis named
thead. Depending on the kind of markup you are parsing, you can use this expression to establish if your element is a part of the innermost table heading.
last content is
last proper content is
last proper subelement is
last subelement is
status of last subelement is
So, for example, you can ask whether
occurrence of open element "item" = 1to find out if you are inside the first item of a list.
The most commonly accessed information is
attributes of and
specified attributes of an element. OmniMark provides the shortcut
attribute notation for
accessing a single item of the
attributes shelf by name for any element. Format items
%v allow for an even shorter notation for accessing the element's name and attributes, but only for the
specified attributes shelves represent the declared and specified
attributes of each element. Each item of these two shelves may have the following properties you can inquire
is cdataand other queries about the declared attribute value type
repeat over attributecan be used to iterate over tokenized attributes such as
name ofthe entity or notation
entitycan be accessed using the appropriate modifiers on
Finally, OmniMark maintains certain information about the parse that is not associated with any particular element, attribute, or entity. This information is bound to the lifetime of the current parse.
number of current subdocuments
#doctype actually provide
information depends on the state of the parsing. They have a value assigned only if the document being parsed,
or the DTD being used to parse it, provides the information. In particular, this means they are never attached
do xml-parseactions prior to a
suppressaction, unless a precompiled DTD is used,
do xml-parseactions after the
document-endrules if errors occurred before this information could be determined.