contentsconceptssyntaxlibrariessampleserrorsindex
Full text search
External text entities: processing  
 

Introduction

This example illustrates the use of the "%q" format item and its associated format modifiers in processing external text entities. Where "%q" gives the name of the entity, "%eq", "%pq", and "%epq" give, respectively, the entity's effective system identifier, declared public identifier, and system identifier mapped from the public identifier in the library declarations.

The external text entity rule in this sample first checks to see if an external text entity has a system identifier. It then checks for a system identifier in the library rules. Finally, it sets the stream "file-name" to the entity name, appending the extension ".ent" if the entity is a parameter entity (the "%" kind), or appending the extension ".sgm" if the entity is a general entity (the "&" kind). Once it has created this file name (using the entity name and the file extension), it checks to see if the file exists and is readable. If so, it passes the text of the file to the XML/SGML parser as the entity's replacement. If not, it issues an error to the #error stream, and provides an XML/SGML comment as the entity's replacement text.



Sample

  external-text-entity #implied
     local stream file-name
     do when entity is system
        set file-name to "%eq"
     else when entity is in-library
        set file-name to "%epq"
     else when entity is parameter
        set file-name to "%lq.ent"
     else
        set file-name to "%lq.sgm"
     done
     do when file file-name exists
         & file file-name is readable
        output file file-name
     else
        put #error "*** error *** can't read from %"%g(file-name)%"%n"
        output
         """%n"

     done

   
----  

Top [CONTENTS] [CONCEPTS] [SYNTAX] [LIBRARIES] [SAMPLES] [ERRORS] [INDEX]

Generated: April 21, 1999 at 2:01:42 pm
If you have any comments about this section of the documentation, send email to [email protected]

Copyright © OmniMark Technologies Corporation, 1988-1999.