Rajpal Kulhari
Rajpal Kulhari

Reputation: 153

Read configuration files in XQuery

I need to read a configuration file (XML or properties file) within an xquery file that is on my local file system i.e. I don't want to put that configuration file in marklogic database. Is there a way to achieve this?

Upvotes: 1

Views: 512

Answers (2)

adamretter
adamretter

Reputation: 3517

You can read the file in as a string as long as it is UTF-8 encoded by using xdmp:filesystem-file you can then turn it into XML by calling xdmp:unquote

xdmp:unquote(xdmp:filesystem-file("c:/config.xml"))

Upvotes: 1

Dave Cassel
Dave Cassel

Reputation: 8422

You can do this and avoid using eval by calling xdmp:document-get(). This will read in a file and have it available in memory. If the file has a .xml extension, it will be read as XML.

Upvotes: 7

Related Questions