swirl Guide to OmniMark 5   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesOMX VariablesErrors
 
  Related Syntax    
rule type   element    

Syntax

  element (element-name (| element-name)* | #implied)  condition?


Purpose

You use element rules to process elements in XML or SGML data. For instance, the following rule processes a "price" element:

  element "price"
     output "$%c"

Every element rule must call "%c" or suppress once and only once. The call may occur in a function called from the rule.

You can have more than one element rule for an element, provided only one of them can be selected at any given time:

  element "price" when parent is "widget"
     ...

  element "price" when parent is "dohickey"
     ...

Note that, unlike find rules, where the first matching rule is fired, even if multiple rules could match the data, element rules require that there always be one and only one selectable rule in all circumstances. Therefore, the following rules will cause an error for a "price" element whose parent is "widget", since either rule could be selected:

  element "price" when parent is "widget"
     ...

  element "price"
     ...

You can have a single rule fire for more than one element type by specifying the list of element names in parentheses separated by the or operator |:

  element ("price" | "cost")
     output "$%c"

If you have many elements for which you want the same processing, you can use an element #implied rule:

  element #implied
     suppress

You can qualify an element #implied rule, just like any other element rule. For instance, you can provide a rule for all the subelements of a paragraph:

  element #implied when parent is "p"
     ...

Information about the current parse state

Much of the processing you want to do in an element rule depends on information about the current state of the parse. The following information is available on the current parse state (some of these items do not apply to XML):

The above keyword can be combined in all the meaningful combinations, so that you can say, for example:

  output attribute "type" of parent of ancestor "listitem"

    Related Syntax
   element
   #implied
 
 
----

Top [ INDEX ] [ CONCEPTS ] [ TASKS ] [ SYNTAX ] [ LIBRARIES ] [ OMX ] [ OMX ] [ ERRORS ]

Generated: August 11, 2000 at 3:07:12 pm
If you have any comments about this section of the documentation, send email to docerrors@omnimark.com

Copyright © OmniMark Technologies Corporation, 1988-2000.