From: Joe W. <jo...@gm...> - 2010-04-25 16:17:00
|
Hi Eric, You've found most of the good ways to handle spaces. Also: - { $first, $last } - { string-join( ($first, $last), ' ') } As to why the space between {$first} and {$last} gets collapsed, I can't recall the explanation, but I'd suggest asking XQuery questions (i.e. not eXist-specific questions) like this on the XQuery talk mailing list: http://www.x-query.com/mailman/listinfo/talk Also, Priscilla Walmsley's XQuery book is a must-buy; I don't have it next to me now, but it's very good at explaining whitespace and namespaces -- two issues that I found most difficult to get my head around in XQuery. Here's a tip: when you're expecting data to appear but it's just not appearing, you've either got your path wrong, or, more likely, the answer is "namespaces." Cheers, Joe On Sun, Apr 25, 2010 at 10:19 AM, Palmer, Eric <ep...@ri...> wrote: > Being new to xquery and exist I'm interested in the best way to put significant whitespace into content in the return clause > > for $bio in collection("/db/bios") > let $first := data($bio/data/bio/person/name/first) > let $last := data($bio/data/bio/person/name/last) > let $space := ' ' > return <li>{$first}{$space}{$last}</li> > > The above works > <li>Shari Motro</li> > > > return <li>{concat($first, ' ', $last)}</li> > > works > <li>Shari Motro</li> > > return ('<li>',$first,$last,'</li>') > > Adds other white space and the <> are escaped into entities > <li> Shari Motro </li> > > And > return <li>{$first} {$last}</li> > > Does not preserve the whitespace > <li>ShariMotro</li> > > What is the best practice way of separating two items with whitespace? > > Thanks > > ------------------------------------------------------------------------------ > _______________________________________________ > Exist-open mailing list > Exi...@li... > https://lists.sourceforge.net/lists/listinfo/exist-open > |