contentsconceptssyntaxlibrariessampleserrorsindex
Full text search
SGML Open Catalog: default external-text-entity rule for SOCAT catalog  
Introduction: SGML Open Catalog library examples  

Sample

  ;
  ; Description
  ;
  ;  This file replaces the OmniMark default external-text-entity rule
  ;  by a rule that is designed to work with a set of SOCAT catalog files
  ;  that have been loaded by the catalog loader in file socat.xin.
  ;  You can use SOCAT catalogs by including this file at the top of
  ;  your OmniMark program, and defining the stream socat on your command
  ;  line or in an argsfile:
  ;
  ;     omnimark -s yourprog -d socat yourcatalog
  ;
  ;
  ;  If you are using more than one catalog, you put them all in one list,
  ;  separating the catalog file names by a system-specific delimiter.
  ;  For example, in UNIX,
  ;
  ;     omnimark -s yourprog -d socat catalog1:catalog2:catalog3
  ;
  ;  or
  ;
  ;     omle -s yourprog -d socat catalog1:catalog2:catalog3
  ;
  ;  If you include this file, but do not define the stream socat on the command
  ;  line, the effect is the same as if you had not included this file.
  ;
  ;  For more information about multiple catalog files and the system-specific
  ;  delimiter, see the file socat.xin.
  ;
  ; Operation
  ;  Attempts are made to resolve the external text entity in the following
  ;  order of priority:
  ;     1. from the socat catalog, if loaded
  ;     2. from system declarations in DTD or library declarations in program
  ;     3. from public identifiers on the #LIBVALUE shelf
  ;     4. by replacing #CHARSET or #CAPACITY entities with a zero-length string
  ;  If all these fail, an error is reported.


  include "socat.xin"     ;catalog loader and catalog manager

  external-text-entity (#IMPLIED | #DTD | #CHARSET | #CAPACITY | #SYNTAX)
     local stream entity-name
     local stream system-object-identifier
     local stream public-identifier
     local stream file-name

     ;get all available information about the entity from the document instance
     set entity-name to "%q"
     do when entity is (system | in-library)
        set system-object-identifier to "%eq"
     else
        set system-object-identifier to ""
     done
     do when entity is public
        set public-identifier to "%pq"
     else
        set public-identifier to ""
     done

     ;Look first in the SOCAT catalog (see socat.xin)
     do
        local stream entity-name-for-lookup
        do when entity is parameter
           ;Parameter entity names are stored in the catalog with a leading
           ;percent character.
           set entity-name-for-lookup to "%%" || entity-name
        else
           ;General entity names are stored in the catalog without change
           set entity-name-for-lookup to entity-name
        done
        set file-name to socat-resolve-entity(entity-name-for-lookup,
              public-identifier, system-object-identifier)
     done

     do when socat-entry-found
        ;entity was evaluated by SOCAT to a system object identifier
        do when file file-name exists
           output file file-name
        else
           put #error "entity %q: file %"" || file-name || "%" not found%n"
           halt
        done

     else when entity is (system | in-library)
        ;entity evaluates to a file name, either directly,
        ;or via a public identifier in a LIBRARY definition
        do when file system-object-identifier exists
           set file-name to system-object-identifier
        else
           repeat over #LIBPATH
              do when file (#LIBPATH || system-object-identifier) exists
                 set file-name to (#LIBPATH || system-object-identifier)
                 exit
              done
           again
        done
        do when file-name != ""
           ;Entity evaluates to the system object identifier of an existing file
           output file file-name
        else
           ;Entity evaluates to a system object identifier, but the system
           ;object identifier does not identify an existing file
           ;Content of error message depends on what kind of entity we have
           put #error "file '" || system-object-identifier || "' for "
           do when entity is (#DTD | #CHARSET | #CAPACITY | #SYNTAX)
              put #error entity-name
              put #error " (%g(#DOCTYPE))" when entity is #DTD
           else when entity is general
              put #error "entity &" || entity-name || ";"
           else
              put #error "entity %%" || entity-name || ";"
           done
           put #error " with public id%n   public %"" ||
                       public-identifier || "%"%n  "
               when entity is public
           put #error " does not exist!%n"
           halt
        done

     else when entity is public & #LIBVALUE has key public-identifier
        ;entity evaluates to a public identifier with associated text
        output #LIBVALUE ^ public-identifier

     else when entity is (#CHARSET | #CAPACITY)
        ; We have no definition for the entity, but zero-length replacement
        ; text is a valid alternative.

     else when entity is public
        ;failed to get either a system object identifier or associated text
        ;even though we had a public identifier
        ;Content of error message depends on what kind of entity we have
        put #error "public identifier for "
        do when entity is (#DTD | #CHARSET | #CAPACITY | #SYNTAX)
           put #error entity-name
           put #error " (%g(#DOCTYPE))" when entity is #DTD
        else when entity is general
           put #error "entity &" || entity-name || ";"
        else
           put #error "entity %%" || entity-name || ";"
        done
        put #error "%n" ||
                   "   public %"" || public-identifier || "%"%n" ||
                   "   is not in the library rules!%n"
        halt

     else
        ;failed to get either a system object identifier or a public identifier
        ;Content of error message depends on what kind of entity we have
        do when entity is #DTD
           put #error "#DTD (%g(#DOCTYPE)) "
        else when entity is general
           put #error "entity &" || entity-name || ";"
        else
           put #error "entity %%" || entity-name || ";"
        done
        put #error " has neither a system nor a public identifier!%n"
        halt
     done

 
----  

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

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

Copyright © OmniMark Technologies Corporation, 1988-1999.