Prety sure you can avoid the text {} and ()  and just do

"Id	Name",
  for $i in $doc/item return
     concat($i/id,  "	", $i/name)


----------------------------------------
David A. Lee
[email protected]<mailto:[email protected]>
http://www.xmlsh.org

From: [email protected] [mailto:[email protected]] On Behalf Of 
Mike Sokolov
Sent: Wednesday, July 18, 2012 3:04 PM
To: Gary Larsen
Cc: [email protected]
Subject: Re: [xquery-talk] Add value to result before a for loop

A more compact alternative:

(
  text { "Id&#9;Name" },
  for $i in $doc/item return
    text { concat($i/id,  "&#9;", $i/name) }
)

This relies on your processor's serialization-as-text to insert the line 
endings.  I'm not totally sure if that's standard, but it seems to work for me 
in one case at least. Can anyone comment on how reliable that is?

-Mike

On 07/18/2012 08:49 AM, Gary Larsen wrote:
Hi,

I can't seem to find valid syntax for output of a value before a for loop.  In 
this example I want to output a header line ($hdr) to the results.

Thanks for your help,
Gary

let $doc :=
<doc>
<item><id>1</id><name>item 1</name></item>
<item><id>2</id><name>item 2</name></item>
</doc>

let $hdr := concat('Id',  codepoints-to-string(9), 'Name',  
codepoints-to-string(10))

for $i in $doc/item return
concat($i/id,  codepoints-to-string(9), $i/name,  codepoints-to-string(10))








_______________________________________________

[email protected]<mailto:[email protected]>

http://x-query.com/mailman/listinfo/talk
_______________________________________________
[email protected]
http://x-query.com/mailman/listinfo/talk

Reply via email to