From: Eric Richardson <eric@mi...> - 2000-12-14 01:20:56
With the help of Mike Smith, I figured out what this problem was. I
responded on the archive but apparently that only went to Mike Noyes.
Hopefully this will help someone.
When opening a xhtml document with psgml it was getting stuck in
sgml-mode which was causing the parse problem. I had a custom hook
that parsed the document on open which worked fine when I did not have
a catalog or a dtd for psgml to use. Once I added a catalog the custom
hook forced psgml into sgml-mode which did not work when the parse
tried to use the xhtml dtd.
I'm not an expert but I'll give some beginner tips for your .emacs
file for editing xml docbook and xhtml.
1. to load psgml and the modes and associate file extensions
(add-to-list 'load-path "/home/maxwell/elisp/psgml-1.2.1/")
(autoload 'sgml-mode "psgml" "Major mode to edit SGML files." t)
(autoload 'xml-mode "psgml" "Major mode to edit XML files." t)
(add-to-list 'auto-mode-alist '("\\.xml\\'" . xml-mode))
(add-to-list 'auto-mode-alist '("\\.html\\'" . xml-mode))
(add-to-list 'auto-mode-alist '("\\.sgml\\'" . sgml-mode))
Here I'm always going to use xhtml(xml-mode) for .html files
2. to get the parse on open:
(setq sgml-auto-activate-dtd t)
3. to be able to add the doctype on a new file. I have docbook xml and
"<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"
"<!DOCTYPE book PUBLIC \"-//OASIS//DTD DocBook XML V4.1.2//EN\"
3. environment file for psgml and nsgmls external parser (sp). I source
this file before running emacs.
# bash env file for sp 1.3.4 to help with XML support
# input in declared encoding or default and output in UTF-8
#Notes: use -wxml for validating or -wno-valid for not valid
export SP_CHARSET_FIXED SP_ENCODING SGML_CATALOG_FILES
4. I downloaded the dtd and entity files from http://www.w3c.org for XHTML
and put them in a directory. Here is the simple catalog file I made
modeling after docbook.
-- xhtml1.cat like docbook catalog file --
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "xhtml1-strict.dtd"
PUBLIC "-//W3C//ENTITIES Latin 1 for XHTML//EN" "xhtml-lat1.ent"
PUBLIC "-//W3C//ENTITIES Symbols for XHTML//EN" "xhtml-symbol.ent"
PUBLIC "-//W3C//ENTITIES Special for XHTML//EN" "xhtml-special.ent"
5. some face highlighting stuff from Karl Eichwalder
(copy-face 'italic 'sgml-tag)
(set-face-background 'sgml-tag "white")
;; (set-face-background 'sgml-tag "grey90")
;; (set-face-foreground 'sgml-tag "grey60")
(set-face-foreground 'sgml-tag "blueviolet")
'((start-tag . sgml-tag)
(end-tag . sgml-tag)
(comment . font-lock-comment-face) ;; comment declaration
;; ignored - ignored marked section
;; ms-end - marked section start, if not ignored
;; ms-start - marked section end, if not ignored
(pi . bold) ;; processing instruction
(sgml .highlight) ;; SGML declaration
(doctype . font-lock-string-face) ;; doctype declaration
(entity . font-lock-reference-face) ;; general entity
(shortref . font-lock-function-name-face)));; short reference
(setq sgml-set-face t)
Hope this helps someone. For me the psgml learning curve
has been a bit tough but it is now well worth it
so hang in there. Thanks to Karl and Mike Smith
for all their help.