PSGML (Configuring)

Re:      PSGML problem 
Author:  Peter Flynn
Date:    1998/10/13
Groups:  comp.text.sgml, comp.text.xml

Oslash;yvind Eide wrote:
> In article <> Arkadiusz Fuss <> writes:
> >   Hi,
> >
> >   I want to use Emacs and PSGML to make my own interface for editing SGML
> >   documents. To parse the DTD I would like to use the parser of PSGML.
> >   My Problem is, I don't know how to activate the parser. I wont to tell
> >   the parser the path and filename of the DTD and the parsing and the
> >   generation of elements a.s.o. should begin.

This is probably an FAQ by now...

1. Assuming you have Emacs installed and working...

2. Put all the psgml*.* files into the site-lisp subdirectory.
   This should be under your Emacs installation directory, for
   example (PC) c:\emacs\emacs-xx.yy\site-lisp or (Unix) something
   like /usr/share/emacs/emacs-xx.yy/site-lisp (this varies according
   to the version of Emacs and the vagaries of whoever installed it).
   Include other bits and pieces like the Dave Megginson's replacement
   psgml files for editing xml, his xpointer mode, or Tony Graham's 
   tdtd mode.

3. Add the following line at the top of your .emacs file (this file
   should be in your login directory, or in c:\ on a PC. Create the
   file if it doesn't already exist.)

  (setq load-path (cons (expand-file-name
"c:/emacs/emacs-xx.yy/site-lisp") load-path))

   (replacing the path in quotes with wherever your site-lisp directory 
   really is). Actually this line should already be there if Emacs has
   been installed properly.

4. Install nsmgls (

5. Create a catalog file somewhere sensible (c:\sgml\catalog or
   Put in it the FPIs and the paths of the DTDs and other files you are
   to use, one per line, in the form:

   PUBLIC "+//Silmaril//DTD Report//EN"

   Check these critically: they MUST be spelled and punctuated
   If you only ever use hard-wired SYSTEM identifiers, you can get away
   without a catalog, but it's a pain keeping them up to date: a catalog
   is much easier.

   If you are using a custom SGML Declaration, add it to this file too:

   SGMLDECL "+//Silmaril//DTD Report//EN"

   DTDDECLs are very nice, but not even nsgmls supports them yet.

6. Add the following lines further down .emacs

   (autoload 'sgml-mode "psgml" "Major mode to edit SGML files." t )
   (setq auto-mode-alist
        '("\\.html$" . sgml-mode)
        '("\\.sgm$" . sgml-mode) 
        '("\\.xml$" . sgml-mode)
        '("\\.dcl$" . dtd-mode)
        '("\\.dec$" . dtd-mode)
        '("\\.dtd$" . dtd-mode)
        '("\\.ent$" . dtd-mode)
        '("\\.mod$" . dtd-mode))
   ;;;(autoload 'xml-mode "psgml" nil t)
   ;;;(autoload 'sgml-xpointer "psgml-xpointer" nil t)
   (setq sgml-validate-command "c:\\sp\\bin\\nsgmls -s
-cc:\\sgml\\catalog %s %s")
   (setq sgml-catalog-files '("c:\\sgml\\catalog" "CATALOG"))
   ;;;(autoload 'dtd-mode "tdtd" "Major mode for SGML and XML DTDs.")

   Uncomment (;;;) the xml and other stuff if you've installed it.
   Add or delete other file extensions in the alists if you want them 
   or not. Change the validate and catalog entries to give the correct
   paths for your copy of nsgmls and your catalog.

7. Save and exit, quit Emacs, and start up again. Opening an SGML file
   now make sgml-mode load, then psgml-mode, and it will then look for
   <!doctype declaration at the top of your file, search the catalog for
   the FPI, locate the DTD file, and parse it. If you add the following
   to your .emacs, you'll even get the code coloured syntactically.


(global-font-lock-mode t)
(setq font-lock-maximum-decoration t)

;; PSGML, courtesy of David Megginson,
(make-face 'sgml-comment-face)
(set-face-foreground 'sgml-comment-face "brown")
(make-face 'sgml-doctype-face)
(set-face-foreground 'sgml-doctype-face "plum")
(make-face 'sgml-end-tag-face)
(set-face-foreground 'sgml-end-tag-face "sky blue")
(make-face 'sgml-ignored-face)
(set-face-foreground 'sgml-ignored-face "gray")
(make-face 'sgml-ms-end-face)
(set-face-foreground 'sgml-ms-end-face "maroon")
(make-face 'sgml-ms-start-face)
(set-face-foreground 'sgml-ms-start-face "maroon")
(make-face 'sgml-pi-face)
(set-face-foreground 'sgml-pi-face "maroon")
(make-face 'sgml-sgml-face)
(set-face-foreground 'sgml-sgml-face "maroon")
(make-face 'sgml-start-tag-face)
(set-face-foreground 'sgml-start-tag-face "sky blue")
(make-face 'sgml-entity-face)
(set-face-foreground 'sgml-entity-face "goldenrod")
(make-face 'sgml-short-ref-face)
(set-face-foreground 'sgml-short-ref-face "firebrick")
(setq-default sgml-markup-faces
              '((comment . sgml-comment-face)
                (doctype . sgml-doctype-face)
                (end-tag . sgml-end-tag-face)
                (ignored . sgml-ignored-face)
                (ms-end . sgml-ms-end-face)
                (ms-start . sgml-ms-start-face)
                (pi . sgml-pi-face)
                (sgml . sgml-sgml-face)
                (start-tag . sgml-start-tag-face)
                (entity . sgml-entity-face)
                (short-ref . sgml-short-ref-face)))
(setq-default sgml-auto-activate-dtd t)
(setq-default sgml-set-face t)

[Note: See the main database entry for PSGML.]

DTDs are not common knowledge because programming students are not
taught markup. A markup language is not a programming language.