markup-comment

rule

Syntax
markup-comment condition?
   action+
    


Purpose

A rule that is performed whenever an SGML or XML comment is found in an SGML or XML document and the condition (if any) is met.

The following statements apply to markup-comment rules:

  • If no markup-comment rule is performed for an SGML or XML comment, then the comment text is discarded.
  • If an OmniMark program contains no markup-comment rules, then all comments are discarded.
  • Only one markup-comment rule may be selected for an SGML or XML comment. That is, either there must be only one markup-comment rule or, if there is more than one, each rule must have a condition so that only one rule applies to any given comment. It is an error for more than one markup-comment rule to be selected for an SGML or XML comment.
  • There may be zero, one, or more than one SGML or XML comment in any declaration in a document, including in a comment declaration.
  • The %c operator captures the text of a comment. Either %c or suppress must be used exactly once in a markup-comment rule. The u, l, s, h, and z format modifiers can be used on a %c operator in a markup-comment rule.
  • The text of a comment consists of all the characters between, but not including, the two comment delimiters (-- and --) and including any record ends or white space within the comment.
  • SGML comments in the SGML Declaration are always ignored, whether or not there are any markup-comment rules in the OmniMark program. All comments in the document prolog (containing the DTD) and document instance are available for processing.
  • The presence of markup-comment rules affects how translate rules match text around a comment in the following fashion:
    1. Any translate rules in progress when the SGML or XML comment is encountered are terminated, and translate rule processing is suspended until the comment is processed.
    2. The comment is processed if one of the markup-comment rules apply to the comment (that is, there is a rule in the currently active groups either with no condition or a condition that succeeds).
    3. The comment is ignored if no markup-comment rules apply.
    4. translate rule processing is resumed.

It is an error for more than one markup-comment rule to be selected for an SGML or XML comment. This means that:

  • there must be only one rule, or
  • if there is more than one rule, each must have a condition or conditions that, when collectively evaluated, allow only one rule to be selected.

This is an example of markup-comment rules with conditions:

  markup-comment when element is "p"
     output " (NOTE: %c)"
  
  
  markup-comment when element isnt "p"
     output "   NOTE: %c%n"
          

Related Syntax