[MarkLogic Dev General] Inserting in a file system module database

Geert Josten geert.josten at dayon.nl
Sat Aug 25 11:22:03 PDT 2012


You can even use it to deploy files within the MarkLogic installation
folder, by using relative paths. Quite handy if you want to use it to
deploy a info studio plugin for instance.

One drawback: the directory must exist.

And as said, the usual sharp knife warnings, especially when writing
within the MarkLogic installation folder.

Cheers,
Geert

-----Oorspronkelijk bericht-----
Van: general-bounces at developer.marklogic.com
[mailto:general-bounces at developer.marklogic.com] Namens Danny Sokolsky
Verzonden: zaterdag 25 augustus 2012 18:54
Aan: MarkLogic Developer Discussion
Onderwerp: Re: [MarkLogic Dev General] Inserting in a file system module
database

You can write to the server using xdmp:save.  It is a privileged
operation, but you can write anywhere that the user under which MarkLogic
runs has permissions.

For example, the following will save a text file to the modules root (on
the filesystem), then in another transaction, get that file, and then
evaluate it as an XQuery module:

xdmp:save(fn:concat(xdmp:modules-root(), "hello.xqy"), text{"'hello'"});

xdmp:document-get(fn:concat(xdmp:modules-root(), "hello.xqy")),

xdmp:invoke("/hello.xqy")

=>
'hello'
hello

As David points out though, it is a sharp tool.

-Danny

-----Original Message-----
From: general-bounces at developer.marklogic.com
[mailto:general-bounces at developer.marklogic.com] On Behalf Of David Lee
Sent: Saturday, August 25, 2012 9:47 AM
To: Florent Georges; MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Inserting in a file system module
database

I don't believe you can write to files directly from the server.
It would be a huge gaping security hole if you could ... (and/or would
require a complex set of authentication )

But back up a level
Database backed Modules are intended for what you are doing.
I am not sure what you mean by  the Module's database default Module
database ... Databases don't have Modules databases associated, App
servers do.

Now if you create an App server, yes it defaults to a filesystem backed
Module DB.
This is just a default, not a recommendation.    For some uses its easier
to put xquery files into a filesystem then  a DB.
But for other users the opposite is  true.  If you want to write module
files directly from within MarkLogic you should use a DB backed modules
directory.     There is also the advantage that it then participates in
all the other databasey things like backups, transactions etc.


--------------------------------------------------------------------------
---
David Lee
Lead Engineer
MarkLogic Corporation
dlee at marklogic.com
Phone: +1 812-482-5224
Cell:  +1 812-630-7622
www.marklogic.com


-----Original Message-----
From: general-bounces at developer.marklogic.com
[mailto:general-bounces at developer.marklogic.com] On Behalf Of Florent
Georges
Sent: Saturday, August 25, 2012 12:08 PM
To: MarkLogic General ML
Subject: [MarkLogic Dev General] Inserting in a file system module
database

  Hi,

  Through an App Server, I insert some modules dynamically in a
database.  How can I do that if the database is on the file system
(which is the case for the default Modules database)?  As far as
I know, xdmp:document-insert() does not work in that case...

  Regards,

--
Florent Georges
http://fgeorges.org/
http://h2oconsulting.be/
_______________________________________________
General mailing list
General at developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
General at developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
General at developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general


More information about the General mailing list