| Syntax 
   external-text-entity entity-name condition?
     action*
 Purpose
 
 A rule used to provide OmniMark's SGML parser with the text of an external text entity (that is an external entity that is not cdata,sdata,ndataorsubdoc) whenever such an entity is referenced in an SGML document. Anexternal-text-entityrule looks like anexternal-data-entityrule. Its most important property is that everything written to the#markup-parserstream within the rule is considered part of the entity's text. For example, this rule specifies that the text of the entity named "version" is the content of the file named "version.txt":
   external-text-entity version
     output file "version.txt"
If an external-text-entityoutputs no text, the SGML parser treats the entity's replacement text as having zero characters. This is not an error. It should be noted that, in a context-translation, an external-text-entityrule can be performed  while thefind-startrules are being performed. This will happen if thefind-startrules output the text of an SGML declaration and there areexternal-text-entityrules for processing the entities represented by the public identifiers in the SGML declaration. The outputaction is usually used inside anexternal-text-entityrule to provide the SGML parser with the entity's replacement text. In anexternal-text-entityrule, the default#current-outputstream contains only the#markup-parserstream. That allows the replacement text of the entity to be fed to the parser usingoutputactions. Because anything written to the #markup-parserstream in anexternal-text-entityrule becomes part of the entity's text, the entity's text can be made up of one or more pieces from one or more sources. If the replacement text of some of the external entities is small, all of the entities can be defined in a single file. This technique can be used to construct a "control file" for configurable documents.
 The external-text-entityrule is unique in OmniMark in that different parts of it are executed in each domain. The header of the rule, and any associated condition, is tested in the output processor. If the rule is selected, the actions within the rule body are performed in the input processor. The reason for this split is:
 The entity reference which triggers the external-text-entityrule is recognized by the SGML parser. Events recognized by the SGML parser cause output processor rules to be triggered. Therefore, the header of theexternal-text-entityrule must belong to the output processor in order for it to be triggered.The contents of the external text entity must be submitted to the SGML parser to be parsed. Only actions that belong to the input processor can supply text to the SGML parser. Therefore, the actions of the external-text-entityrule must be executed in the input processor.
 In practice, it will be irrelevant to most programmers that the rule header is tested in the markup processor and the actions executed in the pattern processor. However, this split has the following implications:
 The currently active groups in the markup processor affect which external-text-entityrules can be selected.Any function called from within the condition at the head of an external-text-entityrule is performed without using the markup processor. Any groups mentioned or modified in anynext group isorusing groupaction are those of the markup processor. In particular, anext group isaction in such a function will change the active groups for the markup processor's currently active groups.In the body of the external-text-entityrule the groups mentioned and modified in anynext group isorusing groupaction are those of the pattern processor. In particular, anynext group isaction changes the pattern processor's currently active groups, and anysubmitin the body of theexternal-text-entityrule selectsfindrules using the pattern processor's currently active groups.
 Versions of OmniMark prior to V3 treated the rule header for the external-text-entityrule as if it were evaluated in the pattern processor, so there may be a change in the behavior forexternal-text-entityrules which are not in the#impliedgroup. It is not expected that this will be a significant change for most programs. Where an external text entity's text does not need processing, it is appropriate that an external-text-entityrule will use anoutputorputaction to provide the file's text to the SGML parser. Even if some processing is required, it can be done with a do scanorrepeat scanin theexternal-text-entityrule, where eachmatchemits the processed text usingoutputorput. On the other hand, if substantial processing is required, it will often be the case that it is more appropriate to submitthe text of the file to be processed byfindrules. In this case, any output of thefindrules that process the submitted text is considered part of the text of the entity. If the findrules are different from those used to process the main input, it will be necessary to use ausing groupprefix on thesubmitaction to specify whichfindrules are used to process the submitted text.  For example:
   external-text-entity #implied when entity is (public & in-library)
     using group entity-processing
        submit file "%pq"
Note that when a category is handled with a condition, all instances failing the condition must be handled using other rules. For example, when using a when #impliedrule, a second rule must be used to handleunless #implied. An output-toaction is allowed in anexternal-text-entityrule.output-toin anexternal-text-entityrule remains in effect until the end of the rule, unless it is overridden by a furtheroutput-to. Usually, the only active output stream in an external-text-entityrule is the#markup-parserstream, so text written using theoutputaction becomes part of the replacement text of the external text entity. Theoutput-toaction allows the OmniMark programmer to redirect the output to another destination. The following code shows how external-text-entityrules can be used to match named entities. The first rule will match all entities named in the program, except the#dtdentity and those used in the SGML Declaration (because they don't have names). This allows the#dtdentity to be processed differently than named entities. The second rule matches all entities in the dtd and the document instance by including both the#dtdand#impliedentities:
   external-text-entity #implied when
  ...
  external-text-entity (#implied | #dtd) when
  ...
 Entity replacement text can also be constructed from multiple sources.  
 The following external-text-entityrule processes any external text entity that has a system identifier. It treats the system identifier as a sequence of file names, separated by semicolons, and concatenates the text from all of the files together as the entity's replacement text.
   external-text-entity #implied when entity is system
     repeat scan "%eq"
     match [any except ";"]+ => file-name
        output file file-name
     match ";"
        ; Ignore any semicolon
     again
An example of an entity with multiple file names is a case where there is a general entity that represents the chapters that comprise the "advanced" part of a textbook:
   <!ENTITY advanced SYSTEM "chapter7.sgm;chapter8.sgm;chapter9.sgm">
 |