From 0edeea71ac64d86cba0bce5ecc58f2e54521d85b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 18 Apr 2023 19:24:52 +0200 Subject: Allow namespaced sxml to add namespaces. --- doc/ref/guile/sxml.texi | 3 +++ module/sxml/namespaced.scm | 3 ++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/ref/guile/sxml.texi b/doc/ref/guile/sxml.texi index 8b0246f7..dd635b4c 100644 --- a/doc/ref/guile/sxml.texi +++ b/doc/ref/guile/sxml.texi @@ -50,6 +50,9 @@ Reads xml from port, and return a namespaced SXML tree. Converts a ``regular'' SXML tree into a namespaced sxml tree. @var{namespaces} must be an association list which maps each prefix used in @var{tree} onto a full XML namespace. + +The key @code{#f} can be used to map non-namespaced elements into a +namespace. @end defun @defun xml tag diff --git a/module/sxml/namespaced.scm b/module/sxml/namespaced.scm index 746b98bb..846f8f25 100644 --- a/module/sxml/namespaced.scm +++ b/module/sxml/namespaced.scm @@ -175,7 +175,8 @@ ((tag) (values tag '()))))) (let ((parts (string-split (symbol->string tag-symb) #\:))) (cons (case (length parts) - ((1) (xml #f (string->symbol (car parts)) attrs)) + ((1) (xml (assoc-ref namespaces #f) + (string->symbol (car parts)) attrs)) ((2) (cond ((assoc-ref namespaces (string->symbol (car parts))) => (lambda (ns) (xml ns (string->symbol (cadr parts)) attrs))) -- cgit v1.2.3