swirl
Guide to OmniMark 8   OmniMark home
docs home 
IndexConceptsTasksSyntaxLibrariesLegacy LibrariesErrors
 
  Related Syntax    
rule  

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 keywords 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 is
   #implied
 
 
 

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

OmniMark 8.2.0 Documentation Generated: March 13, 2008 at 3:33:48 pm
If you have any comments about this section of the documentation, please use this form.

Copyright © Stilo International plc, 1988-2008.