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

2014-06-25 Thread Erik Zander
Thank you Mike

The solution using  constructors worked great.

Regards
Erik

-Ursprungligt meddelande-
Från: Michael Blakeley [mailto:m...@blakeley.com] 
Skickat: den 24 juni 2014 18:02
Till: MarkLogic Developer Discussion
Ämne: Re: [MarkLogic Dev General] Sending document node as parameter to 
xdmp:xslt-invoke

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,$imagePara
> ms,{xdmp:database($metaDatabase)}<
> /database> ) 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)  name="{ thumbsBaseDir }" as="{ xs:string }"/>http://marklogic.com/xdmp/map";>

97891
> 44027975/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] 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


[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