Skip to content
Snippets Groups Projects
Commit 4aade289 authored by Stefan Hynek's avatar Stefan Hynek :drooling_face:
Browse files

fix(whitespaces): do not purge single spaces

nodes consisting of only a single whitespace can occur and thus may not be purged

closes #3
parent 662ad79a
Branches 3-c-text
No related tags found
1 merge request!8Resolve "whitespace handling"
...@@ -52,8 +52,8 @@ declare default element namespace "http://www.tei-c.org/ns/1.0"; ...@@ -52,8 +52,8 @@ declare default element namespace "http://www.tei-c.org/ns/1.0";
declare function whitespace:text declare function whitespace:text
( $text as text()*, $escape-char as xs:string? ) as text()* { ( $text as text()*, $escape-char as xs:string? ) as text()* {
let $whitespace-node := $text[matches(., "[\s\n\r\t]") and normalize-space(.) = ""] let $whitespace-node := $text[matches(., "[\n\r\t]") and normalize-space(.) = ""]
let $single-whitespace-between-nodes := $text = " "
return return
if (not($whitespace-node)) then ( if (not($whitespace-node)) then (
...@@ -85,16 +85,3 @@ declare function whitespace:escape-text ...@@ -85,16 +85,3 @@ declare function whitespace:escape-text
text {replace($text, '[\s]+', $escape)} 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
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment