That hack also works outside cq. I've used it for a number of 
applications, and just tested it with an HTTP server. The server is 
perfectly happy to serialize a sequence of XML and non-XML items. You 
can even serialize binary nodes in the same sequence, if you like.

$ cat test.xqy
(: test.xqy :)
'<?xml version="1.0"?>',
<test/>,
binary { xs:hexBinary('cafebabe') }

$ wget [...]/test.xqy | od -cx
   HTTP/1.1 200 OK
   Server: MarkLogic
   Content-Type: text/plain; charset=UTF-8
   Content-Length: 34
   Connection: Keep-Alive
   Keep-Alive: timeout=1, max=96
0000000   <   ?   x   m   l       v   e   r   s   i   o   n   =   "   1
            3f3c    6d78    206c    6576    7372    6f69    3d6e    3122
0000020   .   0   "   ?   >  \n   <   t   e   s   t   /   >  \n 312 376
            302e    3f22    0a3e    743c    7365    2f74    0a3e    feca
0000040 272 276
            beba
0000042

In passing, I'll add that the cq tool doesn't take much notice of which 
button you press. Certainly that information isn't used for 
serialization options. Primarily, the button pressed is used to set the 
Content-Type header for browser display. What happens next is up to the 
browser.

-- Mike

On 2010-08-31 08:34, Ron Hitchens wrote:
>
>     Yeah, it's an ugly hack and only really works
> in the context of CQ.  Forget I mentioned it.  :-)
> You're better off adding the not-a-PI XML declaration
> to the serialized XML outside of MarkLogic/XQuery as
> needed.
>
> On Aug 31, 2010, at 4:17 PM, Florent Georges wrote:
>
>> Ron Hitchens wrote:
>>
>>   Hi,
>>
>>> The XML declaration is a processing instruction
>>
>>   Really, the XML declaration is not a PI.  It looks like a PI,
>> it smells like a PI, but the XML recommendation says it is not a
>> PI, it is the XML declaration.  That is important because you can
>> not expect to have it in XDM (for instance like a lot of people
>> want to access CDATA sections in an XDM instance).
>>
>>> let $prolog := '<?xml version="1.0" encoding="UTF-8"?>'
>>> let $newXML := element result { ...
>>> return ($prolog, $newXML)
>>
>>   Well, if you ask you serializer to use the XML method, that
>> should result to&_lt;...?&_gt;<result>  ...  If you try it within
>> CQ, you get this result when you ask for the "XML", but strangely
>> enough you get '<?...?><result>  ...' when asking for the "Text"
>> (but this is neither a proper text nor xml method, by my reading
>> of the serialization recommendation).
>>
>>   Regards,
>>
>> --
>> Florent Georges
>> http://fgeorges.org/
>>
>>
>>
>>
>> _______________________________________________
>> General mailing list
>> [email protected]
>> http://developer.marklogic.com/mailman/listinfo/general
>
> ---
> Ron Hitchens {mailto:[email protected]}   Ronsoft Technologies
>       +44 7879 358 212 (voice)          http://www.ronsoft.com
>       +1 707 924 3878 (fax)              Bit Twiddling At Its Finest
> "No amount of belief establishes any fact." -Unknown
>
>
>
>
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general

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

Reply via email to