jbrehr
jbrehr

Reputation: 815

xquery typeswitch introduces spaces?

I’m having a small issue with extra spaces in the output of typeswitch (eXist 5.3) that I don’t know how to solve. Given this small example:

xquery version "3.1";
declare namespace tei="http://www.tei-c.org/ns/1.0";
declare function local:test($nodes as node()*)
{
    for $node in $nodes
    return
        typeswitch ($node)
        case element (test) return
            local:test($node/(node()|text()))
        case element (tei:seg) return
            local:test($node/(node()|text()))
        case element (tei:num) return
            local:test($node/(node()|text()))
        case element (tei:w) return
            local:test($node/(node()|text()))
        case element (tei:gap) return
            "[...]"
        case text() return
            $node/string()
        default return
            local:test($node/(node()|text()))
};

let $node :=
<test>
<seg xmlns="http://www.tei-c.org/ns/1.0" n="1" type="unite" xml:id="cat_agr_s1_u1">
   <seg type="title" resp="#apocryphe">
      <num value="1"> I</num>. <w xml:id="w_cato_agr_2" lemma="quomodo">Quomodo</w>
      <w xml:id="w_cato_agr_3" lemma="ager">agrum</w>
      <w xml:id="w_cato_agr_4" lemma="emo">emi</w> ,
      <w xml:id="w_cato_agr_5" lemma="pararique">pararique</w>
      <w xml:id="w_cato_agr_6" lemma="oporteo">oporteat</w>. 
   </seg>
   <gap reason="editorial" unit="word" quantity="182"> </gap>
</seg>
</test>
return
    <p>{local:test($node)}</p>

I get this output:

<p> I .  Quomodo agrum emi  ,
               pararique oporteat . 
            [...]</p>

But what I am looking for is the following - where the punctutation is not separated by a space from the text:

<p> I. Quomodo agrum emi, pararique oporteat. [...]</p>

Bear in mind that in production the content inside <p> may be mixed in final html output.

Upvotes: 0

Views: 55

Answers (0)

Related Questions