Re: Construct an XdmMap from JSON file (for use as XQuery context item)
Michael Kay <mike-JkSD5nQpfvpWk0Htik3J/[email protected]>
| Newsgroups | gmane.text.xml.saxon.help |
|---|---|
| Message-ID | <[email protected]> |
No, there's no equivalent to the DocumentBuilder at the s9api level. One approach is simply to issue a query that invokes fn:json-doc() on a URI supplied as a parameter.
You can also do something like:
XdmFunctionItem parseJson = XdmFunctionItem.getSystemFunction(proc, new QName(NamespaceConstant.FN, "parse-json"), 1);
XdmMap result = (XdmMap) fi.call(proc, new XdmAtomicValue("{\"colour\":\"green\"}"));
Michael Kay
Saxonica
> On 4 Aug 2020, at 12:28, Andreas Sewe <andreas_sewe-+IBl0H0C+Lsf95zv9F5CbQC/[email protected]> wrote:
>
> Hi,
>
> I am using the S9API and am wondering to how set an XQueryEvaluator's
> context item to a map obtained from a JSON file. For XML inputs I do the
> following
>
> XQueryEvaluator evaluator = executable.load();
> XdmItem contextItem =
> processor.newDocumentBuilder().build(new StreamSource(xml));
> evaluator.setContextItem(contextItem);
>
> But for JSON inputs I haven't found an analogue of DocumentBuilder. Does
> it exist somewhere? If so, where?
>
> Best wishes,
>
> Andreas
>
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/saxon-help
_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
[email protected]
https://lists.sourceforge.net/lists/listinfo/saxon-help