From 9b56ebd22e3267cedc839e11ee31d69928214ce5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Tue, 24 Aug 2021 19:40:36 +0200 Subject: Allow partial change and removal of XML Namespaces. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Changing the error to a returnu allows a partial namespace change map, which can sometimes be usefull (and should hopefully not lead to any issues here). Changing assoc-ref to assoc allows the removal of namespaces, since assoc-ref can't differentiate between a match with #f in its cdr, and no match. (assoc-ref '((a . #f)) 'a) ⇒ #f (assoc-ref '((a . #f)) 'b) ⇒ #f --- tests/xml-namespace.scm | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/xml-namespace.scm (limited to 'tests') diff --git a/tests/xml-namespace.scm b/tests/xml-namespace.scm new file mode 100644 index 00000000..74053fd8 --- /dev/null +++ b/tests/xml-namespace.scm @@ -0,0 +1,30 @@ +(((sxml namespace) + move-to-namespace + )) + + +(test-equal "Move unnamespaced to namespace" + '(NEW:test) + (move-to-namespace '(test) '((#f . NEW)))) + +(test-equal "Swap namespaces" + '(b:a (a:b)) + (move-to-namespace '(a:a (b:b)) '((a . b) (b . a)))) + +(test-equal "Remove all namespaces" + '(a (b)) + (move-to-namespace '(a:a (b:b)) #f)) + +(test-equal "Move everything to one namespace" + '(c:a (c:b)) + (move-to-namespace '(a:a (b:b)) 'c)) + +(test-equal "Partial namespace change" + '(c:a (b:b)) + (move-to-namespace '(a:a (b:b)) + '((a . c)))) + +(test-equal "Remove specific namespace" + '(a:a (b)) + (move-to-namespace '(a:a (b:b)) + '((b . #f)))) -- cgit v1.2.3