Re: [MarkLogic Dev General] How to access XML config files from a modules database instead of content database?

2014-09-15 Thread Tim
Hi Folks,

 

Thanks for all the replies. I think I convinced the team to add it to a content 
(instead of modules) directory URI that can be partially deployed. That way I 
can simply access the content via doc($uri).

 

J Tim

 

From: general-boun...@developer.marklogic.com 
[mailto:general-boun...@developer.marklogic.com] On Behalf Of Joe Bryan
Sent: Monday, September 15, 2014 1:26 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] How to access XML config files from a 
modules database instead of content database?

 

Hi Tim,

 

Here's a simple example that may help. This will return the URI of the first 
XML file in the modules database:

 

xdmp:invoke-function(function() {

cts:uris()[fn:ends-with(., ".xml")][1]

  },

  

{ xdmp:modules-database() }

  )

 

You can replace the cts:uris() expression with 
fn:doc("/path/to/config/file.xml"), and that should suite your needs.

 

However, this approach is a little verbose, so you may want to create a utility 
function that accepts a $uri. Or you could use the utility function that is 
shipped with the REST API:

 

import module namespace dbut = "http://marklogic.com/rest-api/lib/db-util"; at 
"/MarkLogic/rest-api/lib/db-util.xqy";

dbut:access-config(function() {

  fn:doc( "/path/to/config/file.xml" )

})

 

Thanks.

 

-jb

 

From: David Lee 
Reply-To: MarkLogic Developer Discussion 
Date: Monday, September 15, 2014 at 12:45 PM
To: MarkLogic Developer Discussion 
Subject: Re: [MarkLogic Dev General] How to access XML config files from a 
modules database instead of content database?

 

If you implement the XML data *as* an XQuery module then you can simply call a 
method on that module to get them. 

If your  'outside' the application then an HTTP request will retrieve them  
(same as an HTML or CSS or JPG)

That is possibly the distinction being suggested ...

if the data is 'static' *in the perspective of the HTTP Client* then putting it 
in the Modules database is a good way to go.


But if  the data is 'static' from the perspective of the code running inside 
MarkLogic then I generally put it in either the documents database associated 
with the app, or its own database, or if its really a small amount of code-like 
configuration data then putting it into an XQuery module that exposes a simple 
getter method is quite easy and efficient. 

 

 

 

 

From: general-boun...@developer.marklogic.com 
[mailto:general-boun...@developer.marklogic.com] On Behalf Of Tim
Sent: Monday, September 15, 2014 12:41 PM
To: 'MarkLogic Developer Discussion'
Subject: Re: [MarkLogic Dev General] How to access XML config files from a 
modules database instead of content database?

 

Hi David,

 

I suppose that is possible, but if the xml config files reside along with the 
xquery code in the modules database, I would expect a better way to access them 
similar to importing an xquery module.  The idea was suggested to me because 
the config files are static to the xquery modules and should be deployed as 
such – in fact I could implement them as data stored in an xquery module.

 

Tim

 

From:general-boun...@developer.marklogic.com 
[mailto:general-boun...@developer.marklogic.com] On Behalf Of David Ennis
Sent: Monday, September 15, 2014 12:24 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] How to access XML config files from a 
modules database instead of content database?

 

​HI.

 

Not sure if this is what you mean - but you can access content from another 
database using things like xdmp:eval and the database option.

 

Kind Regards,

David Ennis




 

 

Kind Regards,

David Ennis

 

 

David Ennis
Content Engineer

 <http://www.hinttech.com/> HintTech 
Mastering the value of content
creative | technology | content

Delftechpark 37i
2628 XJ Delft
The Netherlands
T: +31 88 268 25 00
M: +31 63 091 72 80 

 <http://www.hinttech.com> http://www.hinttech.com  
<https://twitter.com/HintTech>   <http://www.facebook.com/HintTech>   
<http://www.linkedin.com/company/HintTech> 

 

On 15 September 2014 18:15, Tim  wrote:

Hi Folks,

I'm wondering how to access XML configuration files from a modules database
while the code is being executed in the context of a content database? Is there
a specific import command that allows me to do this?

Tim M.


___
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general

 

___
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general


Re: [MarkLogic Dev General] How to access XML config files from a modules database instead of content database?

2014-09-15 Thread Joe Bryan
Hi Tim,

Here's a simple example that may help. This will return the URI of the first 
XML file in the modules database:

xdmp:invoke-function(function() {
cts:uris()[fn:ends-with(., ".xml")][1]
  },
  
{ xdmp:modules-database() }
  )

You can replace the cts:uris() expression with 
fn:doc("/path/to/config/file.xml"), and that should suite your needs.

However, this approach is a little verbose, so you may want to create a utility 
function that accepts a $uri. Or you could use the utility function that is 
shipped with the REST API:

import module namespace dbut = "http://marklogic.com/rest-api/lib/db-util"; at 
"/MarkLogic/rest-api/lib/db-util.xqy";
dbut:access-config(function() {
  fn:doc( "/path/to/config/file.xml" )
})

Thanks.

-jb

From: David Lee mailto:david@marklogic.com>>
Reply-To: MarkLogic Developer Discussion 
mailto:general@developer.marklogic.com>>
Date: Monday, September 15, 2014 at 12:45 PM
To: MarkLogic Developer Discussion 
mailto:general@developer.marklogic.com>>
Subject: Re: [MarkLogic Dev General] How to access XML config files from a 
modules database instead of content database?

If you implement the XML data *as* an XQuery module then you can simply call a 
method on that module to get them.
If your  'outside' the application then an HTTP request will retrieve them  
(same as an HTML or CSS or JPG)
That is possibly the distinction being suggested ...
if the data is 'static' *in the perspective of the HTTP Client* then putting it 
in the Modules database is a good way to go.

But if  the data is 'static' from the perspective of the code running inside 
MarkLogic then I generally put it in either the documents database associated 
with the app, or its own database, or if its really a small amount of code-like 
configuration data then putting it into an XQuery module that exposes a simple 
getter method is quite easy and efficient.




From: 
general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com>
 [mailto:general-boun...@developer.marklogic.com] On Behalf Of Tim
Sent: Monday, September 15, 2014 12:41 PM
To: 'MarkLogic Developer Discussion'
Subject: Re: [MarkLogic Dev General] How to access XML config files from a 
modules database instead of content database?

Hi David,

I suppose that is possible, but if the xml config files reside along with the 
xquery code in the modules database, I would expect a better way to access them 
similar to importing an xquery module.  The idea was suggested to me because 
the config files are static to the xquery modules and should be deployed as 
such – in fact I could implement them as data stored in an xquery module.

Tim

From:general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com>
 [mailto:general-boun...@developer.marklogic.com] On Behalf Of David Ennis
Sent: Monday, September 15, 2014 12:24 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] How to access XML config files from a 
modules database instead of content database?

​HI.

Not sure if this is what you mean - but you can access content from another 
database using things like xdmp:eval and the database option.

Kind Regards,
David Ennis



Kind Regards,
David Ennis


David Ennis
Content Engineer

[HintTech] <http://www.hinttech.com/>
Mastering the value of content
creative | technology | content

Delftechpark 37i
2628 XJ Delft
The Netherlands
T: +31 88 268 25 00
M: +31 63 091 72 80

[http://www.hinttech.com]<http://www.hinttech.com> 
[http://www.hinttech.com/signature/Twitter_HintTech.png] 
<https://twitter.com/HintTech>  
[http://www.hinttech.com/signature/Facebook_HintTech.png] 
<http://www.facebook.com/HintTech>  
[http://www.hinttech.com/signature/Linkedin_HintTech.png] 
<http://www.linkedin.com/company/HintTech>

On 15 September 2014 18:15, Tim mailto:t...@aaom.net>> wrote:
Hi Folks,

I'm wondering how to access XML configuration files from a modules database
while the code is being executed in the context of a content database? Is there
a specific import command that allows me to do this?

Tim M.


___
General mailing list
General@developer.marklogic.com<mailto:General@developer.marklogic.com>
http://developer.marklogic.com/mailman/listinfo/general

___
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general


Re: [MarkLogic Dev General] How to access XML config files from a modules database instead of content database?

2014-09-15 Thread David Lee
If you implement the XML data *as* an XQuery module then you can simply call a 
method on that module to get them.
If your  'outside' the application then an HTTP request will retrieve them  
(same as an HTML or CSS or JPG)
That is possibly the distinction being suggested ...
if the data is 'static' *in the perspective of the HTTP Client* then putting it 
in the Modules database is a good way to go.

But if  the data is 'static' from the perspective of the code running inside 
MarkLogic then I generally put it in either the documents database associated 
with the app, or its own database, or if its really a small amount of code-like 
configuration data then putting it into an XQuery module that exposes a simple 
getter method is quite easy and efficient.




From: general-boun...@developer.marklogic.com 
[mailto:general-boun...@developer.marklogic.com] On Behalf Of Tim
Sent: Monday, September 15, 2014 12:41 PM
To: 'MarkLogic Developer Discussion'
Subject: Re: [MarkLogic Dev General] How to access XML config files from a 
modules database instead of content database?

Hi David,

I suppose that is possible, but if the xml config files reside along with the 
xquery code in the modules database, I would expect a better way to access them 
similar to importing an xquery module.  The idea was suggested to me because 
the config files are static to the xquery modules and should be deployed as 
such – in fact I could implement them as data stored in an xquery module.

Tim

From: 
general-boun...@developer.marklogic.com<mailto:general-boun...@developer.marklogic.com>
 [mailto:general-boun...@developer.marklogic.com] On Behalf Of David Ennis
Sent: Monday, September 15, 2014 12:24 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] How to access XML config files from a 
modules database instead of content database?

​HI.

Not sure if this is what you mean - but you can access content from another 
database using things like xdmp:eval and the database option.

Kind Regards,
David Ennis



Kind Regards,
David Ennis


David Ennis
Content Engineer

[HintTech] <http://www.hinttech.com/>
Mastering the value of content
creative | technology | content

Delftechpark 37i
2628 XJ Delft
The Netherlands
T: +31 88 268 25 00
M: +31 63 091 72 80

[http://www.hinttech.com]<http://www.hinttech.com> 
[http://www.hinttech.com/signature/Twitter_HintTech.png] 
<https://twitter.com/HintTech>  
[http://www.hinttech.com/signature/Facebook_HintTech.png] 
<http://www.facebook.com/HintTech>  
[http://www.hinttech.com/signature/Linkedin_HintTech.png] 
<http://www.linkedin.com/company/HintTech>

On 15 September 2014 18:15, Tim mailto:t...@aaom.net>> wrote:
Hi Folks,

I'm wondering how to access XML configuration files from a modules database
while the code is being executed in the context of a content database? Is there
a specific import command that allows me to do this?

Tim M.


___
General mailing list
General@developer.marklogic.com<mailto:General@developer.marklogic.com>
http://developer.marklogic.com/mailman/listinfo/general

___
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general


Re: [MarkLogic Dev General] How to access XML config files from a modules database instead of content database?

2014-09-15 Thread Tim
Hi David,

 

I suppose that is possible, but if the xml config files reside along with the 
xquery code in the modules database, I would expect a better way to access them 
similar to importing an xquery module.  The idea was suggested to me because 
the config files are static to the xquery modules and should be deployed as 
such – in fact I could implement them as data stored in an xquery module.

 

Tim

 

From: general-boun...@developer.marklogic.com 
[mailto:general-boun...@developer.marklogic.com] On Behalf Of David Ennis
Sent: Monday, September 15, 2014 12:24 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] How to access XML config files from a 
modules database instead of content database?

 

​HI.

 

Not sure if this is what you mean - but you can access content from another 
database using things like xdmp:eval and the database option.

 

Kind Regards,

David Ennis




 

 

Kind Regards,

David Ennis

 

 

David Ennis
Content Engineer

 <http://www.hinttech.com/> HintTech 
Mastering the value of content
creative | technology | content

Delftechpark 37i
2628 XJ Delft
The Netherlands
T: +31 88 268 25 00
M: +31 63 091 72 80 

 <http://www.hinttech.com> http://www.hinttech.com  
<https://twitter.com/HintTech>   <http://www.facebook.com/HintTech>   
<http://www.linkedin.com/company/HintTech> 

 

On 15 September 2014 18:15, Tim  wrote:

Hi Folks,

I'm wondering how to access XML configuration files from a modules database
while the code is being executed in the context of a content database? Is there
a specific import command that allows me to do this?

Tim M.


___
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general

 

___
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general


Re: [MarkLogic Dev General] How to access XML config files from a modules database instead of content database?

2014-09-15 Thread David Ennis
​HI.

Not sure if this is what you mean - but you can access content from another
database using things like xdmp:eval and the database option.

Kind Regards,
David Ennis



Kind Regards,
David Ennis


David Ennis
*Content Engineer*

[image: HintTech]  
Mastering the value of content
creative | technology | content

Delftechpark 37i
2628 XJ Delft
The Netherlands
T: +31 88 268 25 00
M: +31 63 091 72 80

[image: http://www.hinttech.com] 
  


On 15 September 2014 18:15, Tim  wrote:

> Hi Folks,
>
> I'm wondering how to access XML configuration files from a modules database
> while the code is being executed in the context of a content database? Is
> there
> a specific import command that allows me to do this?
>
> Tim M.
>
>
> ___
> General mailing list
> General@developer.marklogic.com
> http://developer.marklogic.com/mailman/listinfo/general
>
___
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general


[MarkLogic Dev General] How to access XML config files from a modules database instead of content database?

2014-09-15 Thread Tim
Hi Folks,

I'm wondering how to access XML configuration files from a modules database
while the code is being executed in the context of a content database? Is there
a specific import command that allows me to do this?

Tim M.


___
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general