|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] [Newbie] Output contains space around each value -- how do I delete the space?G. Ken Holman gkholman at CraneSoftwrights.comSat Apr 3 10:18:57 PST 2010
At 2010-04-03 10:05 -0400, Costello, Roger L. wrote:
>I have an XQuery that extracts all the data in a bookstore XML
>document and formats the output as slash-delimited values. Here's my XQuery:
>
>-------------------------------------------------------
>declare namespace saxon = "http://saxon.sf.net/";
>declare option saxon:output "indent=no";
>declare option saxon:output "method=text";
>
>let $source := doc("bookstore.xml")
>
>return
> (
> string($source/bookstore/@storename),
> "
>",
> for $i in $source//book return
> (
> string($i/title),
> "/",
> string($i/author[1]),
> "/",
> string($i/date),
> "/",
> string($i/ISBN),
> "/",
> string($i/publisher),
> "/",
> string($i/cost[@currency='USD']),
> "
>"
> )
> )
>-------------------------------------------------------
>
>The XQuery does almost exactly what I desire. However, there is a
>space around each value. Here's the output:
>
>The ABC Book Store
> The Origin of Wealth / Eric D. Beinhocker / 2006 / 1-57851-777-X /
> Harvard Business School Press / 29.95
>...
>Why am I getting spaces around each value?
Because when two strings are added to the result, they are separted by spaces.
>How do I delete those spaces?
Typically you would use concat(), but in your case of having a slash
delimiter, you need only use string-join():
for $i in $source//book return
string-join( (
string($i/title),
string($i/author[1]),
string($i/date),
string($i/ISBN),
string($i/publisher),
string($i/cost[@currency='USD'])
),
"/" )
I hope this helps.
. . . . . . . . Ken
--
XSLT/XQuery training: San Carlos, California 2010-04-26/30
Principles of XSLT for XQuery Writers: San Francisco,CA 2010-05-03
XSLT/XQuery training: Ottawa, Canada 2010-05-10/14
XSLT/XQuery/UBL/Code List training: Trondheim,Norway 2010-06-02/11
Vote for your XML training: http://www.CraneSoftwrights.com/q/i/
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/q/
G. Ken Holman mailto:http://x-query.com/mailman/listinfo/talk
Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/q/bc
Legal business disclaimers: http://www.CraneSoftwrights.com/legal
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart


![[Newbie] Output contains space around each
value -- how do I delete the space?](/images/get_stylus.gif)





