You have a few typos, but fixing those your core problem is you are outputting 
a string "<br/>" which is correctly HTML encoded as a *string*
Try this:

xdmp:set-response-content-type("text/html"),
let $userId  := "1006802"
let $user := /user[userId=$userId]
let $registrations := $user/registeredBooks/registration
let $response := (

             fn:concat ("userId         : ", $userId),
             fn:concat ("email          : ", $user/email/text()),
             fn:concat ("userType       : ", $user/userType/text())
             )

return

       (
             '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>',
             <html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en">
             <body>
                 <b>{$userId}</b><br/>
                 {
                   for $line in $response
                   return ($line, <br/>)
                 }

             </body></html>

       )


-----------------------------------------------------------------------------
David Lee
Lead Engineer
MarkLogic Corporation
[email protected]
Phone: +1 812-482-5224
Cell:  +1 812-630-7622
www.marklogic.com<http://www.marklogic.com/>


From: [email protected] 
[mailto:[email protected]] On Behalf Of Danny Sinang
Sent: Wednesday, September 05, 2012 9:51 AM
To: general
Subject: [MarkLogic Dev General] HTML Output

Hi,

I'm trying to output data in HTML format, but I can't get the ending <br/> to 
be recognized as HTML (i.e. it shows up as part of the output instead of 
causing a line feed).

Any ideas ?

Regards,
Danny

=======================================================================================================

xdmp:set-response-content-type("text/html"),
let $userId  := "1006802"
let $user := /user[userId=$userId]
let $registrations := $user/registeredBooks/registration
let $response := (

             fn:concat ("userId         : ", $userId),
             fn:concat ("email          : ", $user/email/text()),
             fn:concat ("userType       : ", $user/userType/text()),
)
return

       (
             '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>',
             <html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en">
             <body>
                 <b>{$userId}</b><b/r>
                 {
                   for $line in $response
                   return fn:concat($line, "<br/>")
                 }

             </body></html>

       )
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to