processing-instruction

rule

Syntax
processing-instruction pattern condition?
   action*

processing-instruction (named pattern)? (valued pattern)? condition?
   action*


Purpose

A processing-instruction rule is selected when a processing instruction occurs whose entire text matches the specified pattern and the specified condition is satisfied. As with other rules, OmniMark performs processing-instruction rules in the order in which they occur in the program.

processing-instruction rules are not permitted in cross-translate programs.

If an SGML document contained "<?newpage>" processing instructions, an OmniMark program that processes these processing instructions could do so using the following rule:

  processing-instruction "newpage"
     output "\newpage{}"

In SGML, processing instructions can also be specified using so-called PI entities. A processing-instruction rule can capture such entities by name by heralding the pattern with named. In this example, the processing-instruction rule uses this feature to re-emit the entity reference:

  processing-instruction named any* => n
     output "&" || n || ";"
To match both the name of the processing instruction and its value, the named pattern can be combined with a valued pattern:
  processing-instruction named letter+ => n valued letter+ => v
     output "[PI NAMED: " || n || ", VALUED: " || v || "]"

The patterns following both named and valued must match the entire processing instruction text they are scanning (be it the name or the value of the processing instruction entity).

named and valued patterns can appear in any order, and both are optional: however, if neither is specified, a plain pattern must be provided instead. If only a valued pattern is specified, the behaviour is as if valued had not been specified: in other words, the following two processing-instruction rules are equivalent

  processing-instruction valued letter+ => v
     output "[PI]"
  
  processing-instruction letter+ => v
     output "[PI]"

Related Syntax