Article View: comp.text.sgml
Article #739Re: Psgml and ECAT
From: Viktor Haag
Date: Wed, 28 Apr 1999 00:00
Date: Wed, 28 Apr 1999 00:00
123 lines
5637 bytes
5637 bytes
Dominic Prakash <dominic01@hotmail.com> writes:
> Hello All,
>
> Recently I installed emacs (20.3.1) and Psgml (1.0.3) in my NT
> box. I am able to open and edit my sgml file.
[snip]
> How can I compile the DTD and use it for different files?
> Thanks and Regards
There seems to have been a certain amount of questions like these
recently, and Dave Pawson has been gently prodding me to provide
a FAQ-like answer for this (that one could include in the NT
Emacs FAQ). Fair enough:
First, a caveat: I'm using Emacs 20.3.7.1 and psgml-mode
1.1.6. What I've tried worked, as far as I can tell, with 20.3.1
and 1.1.6, but I can't rightly remember.
There's isn't currently a "Is there a mode for editing SGML
instances?" entry in the NTEmacs FAQ, and perhaps their should
be... so here's the start of one (Andrew or Geoff, feel free to
amplify and include in the FAQ if you like). If someone knows a
better, more "natural" way of accomplishing the compiled DTDs
business, please feel free to amend my FAQ entry! I'm only
providing the technique that I use -- it's laborious (slightly),
but it works (and it's maintenance free, once the compiled DTD
exists, and is cataloged properly).
Is there a mode for editing SGML source?
++++++++++++++++++++++++++++++++++++++++
Yes. Lennart Staflin has a mode called "PSGML" for editing SGML
coded documents. You can find the package's web page at:
http://www.lysator.liu.se/projects/about_psgml.html
How do I handle "compiled DTDs" in PSGML, so that I can easily
use them for different files?
-----------------------------
PSGML (by default) seems to want to put compiled DTDs in the
same directory as the current buffer's instance. And for the
default name of the compiled DTD it uses the basename of the
current buffer's instance. Suppose you want to put a compiled DTD
along with the uncompiled DTD, so that all your instances can use
it (especially useful for HTML DTDs, for example)?
Here's a technique that works -- I assume that you've already set
up PSGML with your DTDs in some central location (as defined by
the "sgml-catalog-files" and "sgml-public-map" variables), and
that you know what an SGML catalog file is.
* Go to the directory that contains your DTDs
* In that directory create a temporary instance that contains
only the <!DOCTYPE> for the DTD you want to compile.
* Parse the DTD (type C-c C-p, invoke sgml-parse-prolog, go to
the end of the buffer and press TAB, or choose DTD->Parse DTD)
* Save the DTD (invoke sgml-save-dtd, or choose DTD->Save Parsed
DTD). Emacs prompts you for a name: provide a sensible one (one
that naturally follows from the DTD's base name)
* In the same directory that contains your SGML catalog(s) (you
know what they are, right?), create a file called "ecatalog" or
something similar. In that file, you enter pairs of the
following form:
public "-//IETF//DTD HTML 3.2//EN" "dtd/html_32.ced"
In this case, you provide the public identifier, and then the
path to the compiled file, *relative to the ecatalog's
location*, NOT relative to the sgml-system-path's location.
* In your .emacs, where you have your SGML config, you'll want
something like this form:
(add-hook 'sgml-mode-hook
(function
(lambda ()
"Config stuff for sgml mode."
(setq sgml-catalog-files
(list
(expand-file-name "/mySGMLpath/catalog")))
(setq sgml-ecat-files
(list
(expand-file-name "/mySGMLpath/ecatalog")))
Now, whenever you load an instance of a document type with a
compiled DTD (*.ced) file, PSGML will automagically locate the
compiled DTD, and load the prolog from it instead of reparsing
the original DTD. To double check where PSGML is getting an
instance's DTD information, you can invoke sgml-general-dtd-info,
or choose DTD->Info->General DTD Info.
PSGML will show you the Doctype associated with the instance, the
Compiled DTD location, and the original DTD location.
(NOTE: for some reason, PSGML seems to display the dtd *twice*
under the "Files used" section of this information, iff there's a
compiled DTD associated with the original. *shrug*.)
Notice also that, as far as I can tell, if you make changes to
the original DTD, and then load an instance, PSGL mode will
notice that the compiled file is out of date, and will ask you if
you want a recompile. However this check will *only* happen if
you *already parsed an instances header file*. If so, you'll need
to kill the buffer, reload the instance file, and reparse the
header. Then PSGML will notice the dependency...
--
Viktor Haag Senior Technical Writer, RIM
"Unix and C are the ultimate computer viruses." -- Richard Gabriel
My opinions are my own, only.
Technical Details
Message-ID:
<wk90bcbiah.fsf@rim.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<7g7lnk$l15$1@nnrp1.dejanews.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fa82c,8efbbedde372ba6e X-Google-Attributes: gidfa82c,public X-Google-Thread: 102b9a,e414c2003a82bdac,start X-Google-Attributes: gid102b9a,public X-Google-Thread: 103b8b,e414c2003a82bdac,start X-Google-Attributes: gid103b8b,public From: Viktor Haag <vhaag@rim.net> Subject: Re: Psgml and ECAT Date: 1999/04/28 Message-ID: <wk90bcbiah.fsf@rim.net> X-Deja-AN: 472012670 X-NNTP-Posting-Host: vhaag.rim.net Sender: vhaag@VHAAG References: <7g7lnk$l15$1@nnrp1.dejanews.com> X-Trace: 28 Apr 1999 16:36:57 -0400, proxy3.rim.net Newsgroups: comp.text.sgml,comp.emacs,gnu.emacs.help