Hi, Florent:
Maybe stating the obvious, sniffing the root node works.
If there's only one root node and that node is an instance of
* a text() node, the document is text
* a binary() node, the document is binary
* an array-node() or object-node(), the document is JSON
* a number-node(), boolean-node(), or null-node(), the document is
non-conformant JSON
If the root node is an instance of element(), processing-instruction(),
or comment() or if there's more than one node, the document is XML.
The following functions can also be useful for format determination:
http://docs.marklogic.com/xdmp:node-kind
http://docs.marklogic.com/xdmp:uri-format
Hoping that helps,
Erik Hennum
________________________________________
From: [email protected]
[[email protected]] on behalf of Florent Georges
[[email protected]]
Sent: Sunday, April 03, 2016 10:41 AM
To: MarkLogic Developer Discussion
Subject: [MarkLogic Dev General] Detecting a JSON document in XQuery
Hii,
>From the document "Working with JSON" (available at
https://docs.marklogic.com/8.0/guide/app-dev/json) it does not seem
possible to detect in XQuery whether a document is a JSON document (as
opposed to an XML document).
That is, detecting from "fn:doc('abc.json')" that the document node is
holding a JSON document (other than looking at *.json in the URI).
Did I miss anything?
Regards,
--
Florent Georges
http://fgeorges.org/
http://h2oconsulting.be/
_______________________________________________
General mailing list
[email protected]
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general