Hi, Raghu: One approach is for the client to indicate the content type so you can pass the appropriate format parameter to xdmp:get-request-body().
In particular, if the client passes the HTTP Content-Type header, you can inspect the mime type with xdmp:get-request-header(). The mime type should match the regular expression (text|application)/([^+]+\+xml|xml) if the body is XML. If the client needs to send a database document URI parameter for other reasons, you can also use the xdmp:uri-format() function to look up the format in the server's mapping table for extensions (which you can modify through the Admin UI). As an alternative, you can use a try / catch expression, attempting to parse the payload as XML and falling back to binary. You can find out what you got from the try / catch by an instance of $doc/binary() or instance of $doc/element() expression to inspect the root node of the document. Hoping that helps, Erik Hennum ________________________________ From: [email protected] [[email protected]] on behalf of Raghu [[email protected]] Sent: Monday, February 25, 2013 1:12 PM To: General MarkLogic Developer Discussion Subject: [MarkLogic Dev General] validate request body xml/binary HI all, I have a requirement let $req-body := xdmp:get-request-body() return if ($req-body is a valid xml) then invoke xmlprocessor.xqy else invoke binaryprocessor.xqy what is the best way to validate, if the request body is an xml or binary(non-xml) content?? Thanks in advance. Raghu
_______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
