diff options
author | Andy Wingo <wingo@pobox.com> | 2010-10-14 12:37:31 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2010-10-14 12:37:31 +0200 |
commit | 4aaa0650e04d17c86f6e9b47294ca9b623bea029 (patch) | |
tree | 5c8d209bcbb7ae5464a904c217caef94b148074a /module/sxml/ssax.scm | |
parent | 37d6f737e7accdfb7ee97a55fb764699e4d27f8a (diff) | |
download | guile-4aaa0650e04d17c86f6e9b47294ca9b623bea029.tar.gz |
ssax: add procs to define parsed entities
* module/sxml/ssax.scm (reset-parsed-entity-definitions!)
(define-parsed-entity!): New heavy-handed knobs for adding to the set
of parsed entity definitions.
Diffstat (limited to 'module/sxml/ssax.scm')
-rw-r--r-- | module/sxml/ssax.scm | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/module/sxml/ssax.scm b/module/sxml/ssax.scm index 8794927e9..9709641d4 100644 --- a/module/sxml/ssax.scm +++ b/module/sxml/ssax.scm @@ -1,6 +1,6 @@ ;;;; (sxml ssax) -- the SSAX parser ;;;; -;;;; Copyright (C) 2009 Free Software Foundation, Inc. +;;;; Copyright (C) 2009, 2010 Free Software Foundation, Inc. ;;;; Modified 2004 by Andy Wingo <wingo at pobox dot com>. ;;;; Written 2001,2002,2003,2004 by Oleg Kiselyov <oleg at pobox dot com> as SSAX.scm. ;;;; @@ -147,6 +147,8 @@ attlist-null? attlist-remove-top attlist->alist attlist-fold + define-parsed-entity! + reset-parsed-entity-definitions! ssax:uri-string->symbol ssax:skip-internal-dtd ssax:read-pi-body-as-string @@ -188,6 +190,25 @@ (define char-tab #\tab) (define nl "\n") +;; This isn't a great API, but a more proper fix will involve hacking +;; SSAX. +(define (reset-parsed-entity-definitions!) + "Restore the set of parsed entity definitions to its initial state." + (set! ssax:predefined-parsed-entities + '((amp . "&") + (lt . "<") + (gt . ">") + (apos . "'") + (quot . "\"")))) + +(define (define-parsed-entity! entity str) + "Define a new parsed entity. @var{entity} should be a symbol. + +Instances of &@var{entity}; in XML text will be replaced with the +string @var{str}, which will then be parsed." + (set! ssax:predefined-parsed-entities + (acons entity str ssax:predefined-parsed-entities))) + ;; if condition is true, execute stmts in turn and return the result of ;; the last statement otherwise, return #f (define-syntax when |