Xpath. Using fn:collection() and fn:base-uri() for getting URI of JSON-files

65 Views Asked by At

I have a folder with several json-files (.json). The task is to get the uri for each json-files in the folder. I use fn:collection and fn:base-uri fo this in xslt-file. But I get an error when I execute fn:base-uri.

Error massage: "The required item type of the first argument of fn:base-uri() is node(); the supplied value map{(:size 55:)} is a map"

I tried the following codeenter image description here

It works for .xml-files (when you change the extension to .xml), but it doesn't work for json-files... I have the following error:enter image description here

Maybe anyone knows the way how can I get uri for json-files. Thank you in advance!

1

There are 1 best solutions below

0
Michael Kay On

Use fn:uri-collection() to get the URIs of the files in the collection, then access them individually using fn:json-doc(). Once parsed, the maps and arrays output by the JSON parser have no notion of identity, and contain no trace of where they came from.