From 4aade28993c597c23aa1bdf59630001f1e5a3d1e Mon Sep 17 00:00:00 2001 From: Stefan Hynek <stefan.hynek@uni-goettingen.de> Date: Tue, 18 Aug 2020 09:08:52 +0200 Subject: [PATCH] fix(whitespaces): do not purge single spaces nodes consisting of only a single whitespace can occur and thus may not be purged closes #3 --- .../intermediate_format/whitespace-handling.xqm | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/modules/intermediate_format/whitespace-handling.xqm b/modules/intermediate_format/whitespace-handling.xqm index d1a3e0e..af0c7f6 100644 --- a/modules/intermediate_format/whitespace-handling.xqm +++ b/modules/intermediate_format/whitespace-handling.xqm @@ -52,8 +52,8 @@ declare default element namespace "http://www.tei-c.org/ns/1.0"; declare function whitespace:text ( $text as text()*, $escape-char as xs:string? ) as text()* { - let $whitespace-node := $text[matches(., "[\s\n\r\t]") and normalize-space(.) = ""] - let $single-whitespace-between-nodes := $text = " " + let $whitespace-node := $text[matches(., "[\n\r\t]") and normalize-space(.) = ""] + return if (not($whitespace-node)) then ( @@ -85,16 +85,3 @@ declare function whitespace:escape-text text {replace($text, '[\s]+', $escape)} }; - -declare function whitespace:remove($nodes as node()*) as node()* { - for $node in $nodes - return - typeswitch ($node) - case text() return - if([matches($node, "[\s\n\r\t]") and normalize-space(.) = ""]) then - () - else - $node - default return - $node -}; -- GitLab