Re: [MarkLogic Dev General] Sending document node as parameter to xdmp:xslt-invoke

2014-06-24 Thread Michael Blakeley
The error message is telling you that what you're passing in is an element 
named images, not a document node.

Invalid coercion: http://marklogic.com/xdmp/map";>

9789144027975/image001.eps

 as document-node()

You're passing in an element because you constructed the map entry using XML:

{$metaDatabase}.

A document node can't live inside an element, so the evaluator unwrapped it for 
you. You can see this happening with a simple test.

map:map(
  http://marklogic.com/xdmp/map";>

  imageMetaData
  { document { '' } }
)
! map:get(., map:keys(.))
! xdmp:describe(.)
=>
text{""}

That's a text node, not a document node.

There are a couple ways to fix this. The most concise is to change the expected 
parameter type:



Another approach - possibly better - is to change the way you build your map. 
You're building a map using direct XML constructors, which is a little awkward 
in this context and makes it impossible to include a document node. Instead you 
could build the map using entry constructors and map:new(), something like this:

map:new(
  (map:entry('imageMetaData', $metaInputDoc),
   map:entry('metaDatabase', $metaDatabase)))

Now you have a map:map item, and its map entries can contain document nodes. 
Here's a test to prove that this works:

map:new(
  (map:entry('imageMetaData', document { '' }),
   map:entry('metaDatabase', document { '' })))
! map:get(., map:keys(.))
! xdmp:describe(.)
=>
document{}
document{}

-- Mike

On 24 Jun 2014, at 08:00 , Erik Zander  wrote:

> Hi all!
>  
> I’m currently working  on a xslt transform driven from xquery and have some 
> parameters including a document node that I want to pass to the xslt.
>  
> However I get an error whit the following code.
>  
> ………
> let $metaInputDoc := xdmp:eval('declare variable $metaInputPath external;
> 
> fn:doc($metaInputPath)',$evalParams,$xqueryevalOptions)
> let $imageParams :=  map:map(
> http://marklogic.com/xdmp/map";>
> 
>imageMetaData   
>  
> {$metaInputDoc}
> 
> 
> metaDatabase
> {$metaDatabase}
> 
> 
> 
> )
> 
> 
> 
> (:here the problems begins:)
> let $metaDocs := 
> xdmp:xslt-invoke("/bilddatabas/Image_transform.xsl",$curDoc,$imageParams,{xdmp:database($metaDatabase)}
>  )
> return $metaDocs
> 
> 
>  
> And the xslt params are declared as follows
>  
> 
>  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"xmlns:db="http://docbook.org/ns/docbook"xmlns:xs="http://www.w3.org/2001/XMLSchema";
>  version="2.0">
> 
> 
> 
> 
>   
>   
>   
>   <-oxygen complains here
> 
> 
>  
> And last the error message
>  
> XDMP-AS: (err:XPTY0004) http://marklogic.com/xdmp/map";>

9789144027975/image001.eps

>  as document-node()
>  
>  
>  
>  
> Is this that it’s not possible to pass a document node as a parameter into an 
> xslt transform from xquery in marklogic or is it that I’m doing it wrong?
>  
> Any help is appreciated J
>  
> Best Regards
> Erik
>  
> ___
> 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 find roles that inherit a privilege

2014-06-24 Thread Michael Blakeley
Doesn't https://docs.marklogic.com/xdmp:privilege-roles do that?

If not, I would start with those roles and recurse. You can look up an entire 
generation of inheritance in each query, and stop when there's nothing more to 
do. In most cases I'd expect that to be faster than checking every role 
individually.

-- Mike

On 24 Jun 2014, at 07:49 , Demian Hess  wrote:

> Given a specific execute privilege, I need to generate a list of roles that 
> have that privilege--including the roles that have inherited the privilege.
> 
> I can call sec:privilege-get-roles() to get the roles to which the privilege 
> is directly attached. However, I don't think it returns the roles that 
> inherit the privilege (please correct me if I am wrong!).
> 
> I can call sec:role-privileges($rolename) to get a list of the privileges and 
> inherited privileges. However, this assumes that I already know the role name.
> 
> I could get a list of all roles and iterate over them and call 
> role-privileges(), but that seems wasteful.
> 
> Is there a better way?
> 
> -- 
> Demian Hess
> Architect | Avalon Consulting, LLC
> M: 301.943.8307 | Fax: 845.367.5496
> LinkedIn: http://www.linkedin.com/company/avalon-consulting-llc
> Google+: http://www.google.com/+AvalonConsultingLLC
> Twitter:https://twitter.com/avalonconsult
> 
> ___
> 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] Sending document node as parameter to xdmp:xslt-invoke

2014-06-24 Thread Erik Zander
Hi all!

I'm currently working  on a xslt transform driven from xquery and have some 
parameters including a document node that I want to pass to the xslt.

However I get an error whit the following code.

.
let $metaInputDoc := xdmp:eval('declare variable $metaInputPath external;

fn:doc($metaInputPath)',$evalParams,$xqueryevalOptions)
let $imageParams :=  map:map(
http://marklogic.com/xdmp/map";>

imageMetaData
{$metaInputDoc}


metaDatabase
{$metaDatabase}



)



(:here the problems begins:)
let $metaDocs := 
xdmp:xslt-invoke("/bilddatabas/Image_transform.xsl",$curDoc,$imageParams,{xdmp:database($metaDatabase)} 
)
return $metaDocs



And the xslt params are declared as follows


http://www.w3.org/1999/XSL/Transform"; 
xmlns:db="http://docbook.org/ns/docbook"; 
xmlns:xs="http://www.w3.org/2001/XMLSchema"; version="2.0">







<-oxygen complains here



And last the error message

XDMP-AS: (err:XPTY0004) http://marklogic.com/xdmp/map";>

9789144027975/image001.eps

 as document-node()




Is this that it's not possible to pass a document node as a parameter into an 
xslt transform from xquery in marklogic or is it that I'm doing it wrong?

Any help is appreciated :)

Best Regards
Erik

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


Re: [MarkLogic Dev General] MarkLogic REST API - CORS Headers

2014-06-24 Thread Michael Blakeley
The built-in REST API endpoints don't seem to support any mechanism for adding 
arbitrary response headers. However you should be able to add your own headers 
when writing a REST extension: 
https://docs.marklogic.com/guide/rest-dev/extensions

For the built-in endpoints you might consider routing requests through another 
app-server layer, or a transparent reverse proxy. Either way the goal would be 
to re-route requests so that the browser thinks both REST API instances are on 
the same server.

-- Mike

On 23 Jun 2014, at 02:17 , Krishna Chaitanya A  
wrote:

> Hello all,
> 
> I am Krishna, a computer science MSc student at TU Delft in the Netherlands. 
> I am using MarkLogic's inbuilt REST APIs to access two document stores. My 
> web application is hosted in the modules database of one of these stores. 
> When I try accessing the second database from my application, I get the 'No 
> Access-Control-Allow-Origin' error in my browser. I have read the 
> documentation regarding xdmp:add-response-header at 
> 
> https://docs.marklogic.com/xdmp%3aadd-response-header
> 
> However, I have not been able to figure out where I can use this to enable 
> CORS. Any help on this would be great!
> 
> Thanks in advance.
> 
> Regards,
> Krishna
> 
> 
> 
> 
> Krishna Chaitanya Akundi
> MSc Student, Web Information Systems
> EEMCS - TU Delft
> The Netherlands
> ___
> 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 find roles that inherit a privilege

2014-06-24 Thread Demian Hess
Given a specific execute privilege, I need to generate a list of roles that
have that privilege--including the roles that have inherited the privilege.

I can call sec:privilege-get-roles() to get the roles to which the
privilege is directly attached. However, I don't think it returns the roles
that inherit the privilege (please correct me if I am wrong!).

I can call sec:role-privileges($rolename) to get a list of the privileges
and inherited privileges. However, this assumes that I already know the
role name.

I could get a list of all roles and iterate over them and call
role-privileges(), but that seems wasteful.

Is there a better way?

-- 
Demian Hess
Architect | Avalon Consulting, LLC
M: 301.943.8307 | Fax: 845.367.5496
LinkedIn: http://www.linkedin.com/company/avalon-consulting-llc
Google+: http://www.google.com/+AvalonConsultingLLC
Twitter:https://twitter.com/avalonconsult
___
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general


Re: [MarkLogic Dev General] Tools for xquery Code Coverage and Code Generation

2014-06-24 Thread manoj viswanadha
Hi rob,

I am trying to write test cases under my own directory. But its not finding
dat. It is only taking directory /xray/tests. Is is there any other way to
achieve this.

Thanks,
Manoj.
On 23 Jun 2014 11:24, "manoj viswanadha"  wrote:

> Hi rob,
>
> Code coverage is working as expected.
>
> Thanks for your help.
>
> Manoj.
> On 21 Jun 2014 09:02, "manoj viswanadha" 
> wrote:
>
>> Hi rob,
>>
>> Thanks. I will try to get the latest code.
>>
>> Thanks,
>> Manoj.
>> On 21 Jun 2014 03:13, "Whitby, Rob"  wrote:
>>
>>> ah sorry there was a bug in the v2.1 branch which I've now fixed, try
>>> pulling the latest. This branch is still experimental, if you have any more
>>> problems please open an issue on github.
>>>
>>> Thanks,
>>> Rob
>>>
>>> 
>>> From: general-boun...@developer.marklogic.com [
>>> general-boun...@developer.marklogic.com] on behalf of manoj viswanadha [
>>> manoj.viswana...@gmail.com]
>>> Sent: 19 June 2014 07:21
>>> To: MarkLogic Developer Discussion
>>> Subject: Re: [MarkLogic Dev General] Tools for xquery Code Coverage and
>>> CodeGeneration
>>>
>>> Hi Rob,
>>>
>>> Thanks for your quick response. I have installed xray and using it
>>> through Marklogic.
>>>
>>> unit tests are running very much fine but i am facing issues with code
>>> coverage.
>>>
>>> It was mentioned in the document that for code coverage we need to pass
>>> parameter code-coverage as query param and should give the path of the
>>> module. I have followed the same steps but still its throwing error. Is
>>> there something which i am missing?
>>>
>>> Thanks,
>>> Manoj.
>>>
>>>
>>> On Tue, Jun 17, 2014 at 4:23 PM, Whitby, Rob >> > wrote:
>>> Xray has code coverage in v2.1.
>>> https://github.com/robwhitby/xray/tree/v2.1
>>>
>>>
>>> From: manoj viswanadha >> manoj.viswana...@gmail.com>>
>>> Reply-To: MarkLogic Developer Discussion <
>>> general@developer.marklogic.com>
>>> Date: Tuesday, 17 June 2014 08:06
>>> To: MarkLogic Developer Discussion >> >
>>> Subject: [MarkLogic Dev General] Tools for xquery Code Coverage and Code
>>> Generation
>>>
>>> Hi all,
>>>
>>> Can anyone suggest some tools for xquery Code Coverage and Code
>>> Generation.
>>>
>>> Thanks in advance,
>>> Manoj
>>>
>>>
>>>
>>> ___
>>> 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
>>>
>>
___
General mailing list
General@developer.marklogic.com
http://developer.marklogic.com/mailman/listinfo/general