contentsconceptssyntaxlibrariessampleserrorsindex
Full text search
SGML Open Catalog: illustrating the use of notations with SGML Open Catalog  
Introduction: SGML Open Catalog library examples  

Sample

  ;
  ; notation.xom -- illustrate use of notations with SGML Open Catalog
  ;
  ; Description
  ;
  ;   Shows how to get information about the notations of external data
  ;   entities in an external-data-entity rule, and how to get information
  ;   about notation attributes in entity rules.
  ;
  ;   Instead of using the notation information to process non-SGML data,
  ;   this program simply displays the information.
  ;
  ;   To run this program, give one of these commands:
  ;
  ;       omnimark -d socat notation.cat -s notation.xom notation.sgm

  down-translate

  ;Assume that SGML Open Catalog also used with external-text-entity rule
  ;
  include "socatete.xin"

  ;How to handle notation attributes
  ;
  element #implied
      local stream not-name initial { "" }
      local stream not-pubid initial { "" }
      local stream not-system initial { "" }
      local stream not-lookup initial { "" }
      output "%n%c"
      repeat over attributes as attr
          do when attribute attr is notation

              ;Collect all available info about the notation
              set not-name to attribute attr
              do when attribute attr is public
                  set not-pubid to "%pv(attr)"
              done
              do when attribute attr is system
                  set not-system to "%ev(attr)"
              done

              ;Look up the notation in the catalog
              set not-lookup to
                  socat-resolve-notation(not-name, not-pubid, not-system)

              ;Display the information.
              ;In an application, you would use this information to process the
              ;element content, instead of simply displaying the information.
              output
                  "notation=" || not-name
                  || ", public=" || not-pubid
                  || ", system=" || not-system
                  || ", catalog=" || not-lookup
                  ||"%n"
          done
      again

  ;How to handle external data entities with notations
  ;
  external-data-entity #implied when entity isnt subdoc-entity
      local   stream entity-type initial { "" }
      local   stream ent-name initial { "" }
      local   stream ent-system initial { "" }
      local   stream ent-pubid initial { "" }
      local stream ent-lookup initial { "" }
      local   stream not-name initial { "" }
      local   stream not-system initial { "" }
      local   stream not-pubid initial { "" }
      local stream not-lookup initial { "" }

      ;Determine the entity type
      do when entity is cdata-entity
          set entity-type to "cdata"
      else when entity is ndata-entity
          set entity-type to "ndata"
      else when entity is sdata-entity
          set entity-type to "sdata"
      done

      ;Collect all available info about the entity
      set ent-name to "%q"
      do when entity is public
          set ent-pubid to "%pq"
      done
      do when entity is system
          set ent-system to "%eq"
      done

      ;Look up the entity in the catalog
      set ent-lookup to socat-resolve-entity(ent-name, ent-pubid, ent-system)

      ;Collect all available info about the notation
      set not-name to "%oq"
      do when notation is public
          set not-pubid to "%poq"
      done
      do when notation is system
          set not-system to "%eoq"
      done

      ;Look up the notation in the catalog
      set not-lookup to socat-resolve-notation(not-name, not-pubid, not-system)

      ;Display the information.
      ;In an application, you would use the notation information to obtain and
      ;process the external data, instead of simply sending the information
      ;to the SGML parser as if it were SGML data.
      output
          "%n" || entity-type
          || " entity=" || ent-name
          || ", public=" || ent-pubid
          || ", system=" || ent-system
          || ", catalog=" || ent-lookup
          || "%n"
      output
          "notation=" || not-name
          || ", public=" || not-pubid
          || ", system=" || not-system
          || ", catalog=" || not-lookup
          ||"%n"

  ;SUBDOC entities never have notations
  ;
  external-data-entity #implied when entity is subdoc-entity
      local   stream ent-name initial { "" }
      local   stream ent-system initial { "" }
      local   stream ent-pubid initial { "" }
      local stream ent-lookup initial { "" }

      ;Collect all available info about the entity
      set ent-name to "%q"
      do when entity is public
          set ent-pubid to "%pq"
      done
      do when entity is system
          set ent-system to "%eq"
      done

      ;Look the entity up in the catalog
      set ent-lookup to socat-resolve-entity(ent-name, ent-pubid, ent-system)

      ;In an application, you would use the entity information to obtain and
      ;process the external document, instead of simply sending the
      ;information to the SGML parser as if it were SGML data.
      output "%nSUBDOC"
          || " entity=" || ent-name
          || ", public=" || ent-pubid
          || ", system=" || ent-system
          || ", catalog=" || ent-lookup
          || "%n"

 
----  

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.