help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why won't PSGML use http system identifiers?


From: Henrik Motakef
Subject: Re: Why won't PSGML use http system identifiers?
Date: 29 Oct 2002 21:03:06 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2

"D. D. Brierton" <darren@dzr-web.com> writes:

> Is there some reason why PSGML has to have all the various DTDs, mod and ent
> files on the local system, as opposed to downloading them via http when the
> system identifier is a URL?

Probably because there isn't a portable way to download something via
HTTP, AFAIK.

Here's a workaround I use. It depends on the Url lib from
<http://www.gnu.org/software/url/>. It is probably a quite stupid way
to do this, but it seems to work for me so far.

  (require 'url)
  
  (defun download-uri-to-string (uri)
    (let* ((buffer (url-retrieve-synchronously uri))
         (data (with-current-buffer buffer
                 (goto-char (point-min))
                 (forward-paragraph)
                 (buffer-substring (point) (point-max)))))
        (kill-buffer buffer)
        data))
  
  (defun my-insert-sysid (sysid)
    (condition-case nil
        (progn (insert (download-uri-to-string sysid)) t)
      (error ; Couldn't download, maybe uri is relative?
       (let ((last-uri 
            (second (third (caar (sgml-entity-text sgml-current-eref))))))
         (condition-case nil
           (progn
             (insert
              (download-uri-to-string 
               (concat (file-name-directory last-uri) sysid)))
             t)
         (error nil))))))
  
  (add-to-list 'sgml-sysid-resolve-functions 'my-insert-sysid)

Would be nice if someone could look at it, and perhaps explain what
I'm doing, esp. in the `(second (third (caar ...' line. If have no
idea if there is some "official" API for the eref structure, or this
code will work with other PSGML versions.

> Basically, I'm trying to set up PSGML mode for XHTML 1.1 and frankly getting
> hold of all the various modules is a complete nightmare, and I'm especially
> concerned that it will prove hard to keep up-to-date. 

I wouldn't expect any major changes in XHTML 1.1 to come :-)

Regards
Henrik


reply via email to

[Prev in Thread] Current Thread [Next in Thread]