Hook for using <?xml-model?> PI with nXML mode
"Tony Graham" <[email protected]>
| Newsgroups | gmane.emacs.nxml.general |
|---|---|
| Message-ID | <[email protected]> |
The <?xml-model?> PI [1] is being jointly developed by W3C and ISO/IEC
JTC1/SC34 as a way to associate schemas with XML documents.
Here's a simple hook function for using the PI when it refers to a RNC
file on the local file system.
Regards,
Tony Graham
Mentea.
[1] http://www.w3.org/TR/xml-model/
--------------------------------------------------
(defun use-xml-model ()
"Hook function for `nxml-mode' to use <?xml-model?> PI for locating a
RNC schema."
(interactive)
(save-excursion
(goto-char (point-min))
(if (search-forward "<?xml-model " nil t)
(progn
(goto-char (match-end 0))
(let* ((pi-end (save-excursion
(search-forward "?>" nil t)
(match-beginning 0)))
(filename (save-excursion
(re-search-forward "href=\"\\([^\"]+\.rnc\\)\""
pi-end t)
(match-string 1))))
;; (message "pi-end: %d; filename: %s; compact: %s"
;; pi-end filename compact)
(if (and filename (file-readable-p filename))
(rng-set-schema-file filename)))))))
(add-hook 'nxml-mode-hook
'use-xml-model)
--------------------------------------
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/emacs-nxml-mode/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/emacs-nxml-mode/join
(Yahoo! ID required)
<*> To change settings via email:
[email protected]
[email protected]
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/