#libpath

built-in shelf

Purpose

A built-in stream shelf whose items specify alternate paths for the system identifiers specified in SGML/XML library declarations. The initial values of #libpath are set using the "-libpath" (or "-l") command-line argument.

The #libpath shelf is initialized from the "-libpath" specifications on the command line only if, somewhere in the OmniMark program, there is some action that initiates SGML or XML parsing (i.e. a do sgml-parse or do xml-parse action). If there is no such markup parsing action, the "-libpath" command-line arguments are ignored.

The default "current-item" is the last item on the shelf, as for programmer-defined shelves.

#libpath is used by the default external text entity manager. The manager uses the values of items as prefixes when it tries to find files to provide replacement text for the current external text entity.

#libpath can be changed at any time, but these changes will affect the processing of the default external-text-entity rule. The default external text entity manager assumes that the items on this shelf are closed and attached to either buffers or referents that can return a value.

This example illustrates how a repeat over loop can be used to iterate over the items on the #libpath shelf. The external text entity rule shown in this example does what OmniMark's built-in entity manager does for entities with system identifiers.

In this example, provision is made for there not being a -libpath argument, which is used as a prefix to produce the name of an existing file. If the external-text-entity rule was missing the halt action, then, apart from the message being written to #error, the OmniMark program would simply continue.

  external-text-entity #implied when entity is system
     local stream file-name
     do when file "%eq" exists
        set file-name to "%eq"
     else
        repeat over #libpath
           do when file "%g(#libpath)%eq" exists
              set file-name to "%g(#libpath)%eq"
              exit
           done
        again
     done
     do when file-name is attached
        output file file-name
     else
        put #error
            "no file found for entity %"%q%", system id = %"%eq%"%n"
        halt
     done