Thank you Mike The solution using constructors worked great.
Regards Erik -----Ursprungligt meddelande----- Från: Michael Blakeley [mailto:[email protected]] 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: <images xmlns:map="http://marklogic.com/xdmp/map"> <image> <name>9789144027975/image001.eps</name> <id...</images> as document-node() You're passing in an element because you constructed the map entry using XML: <map:value>{$metaDatabase}</map:value>. 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( <map:map xmlns:map="http://marklogic.com/xdmp/map"> <map:entry> <map:key>imageMetaData</map:key> <map:value>{ document { '' } }</map:value> </map:entry></map:map>) ! 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: <xsl:param name="imageMetaData" as="element()"/> 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 <[email protected]> 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( > <map:map xmlns:map="http://marklogic.com/xdmp/map"> > <map:entry> > <map:key>imageMetaData</map:key> > > <map:value>{$metaInputDoc}</map:value> > </map:entry> > <map:entry> > <map:key>metaDatabase</map:key> > <map:value>{$metaDatabase}</map:value> > </map:entry> > <map:entry> > > </map:map>) > > > > (:here the problems begins....:) > let $metaDocs := > xdmp:xslt-invoke("/bilddatabas/Image_transform.xsl",$curDoc,$imagePara > ms,<optionsxmlns="xdmp:eval"><database>{xdmp:database($metaDatabase)}< > /database></options> ) return $metaDocs > > > > And the xslt params are declared as follows > > <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet > 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"> > <!-- Paramaters to the transform --> > > <!--imageMetaData is the metadata created when the thumbnails are > created--> > <xsl:param name="imageMetaData" as="document-node()"/> > > > > <-oxygen complains here > <xsl:param name="metaDatabase"/> > > > And last the error message > > XDMP-AS: (err:XPTY0004) <xsl:param name="{ imageMetaData }" as="{ > document-node() }"/><xsl:param name="{ metaDatabase }"/><xsl:param > name="{ thumbsBaseDir }" as="{ xs:string }"/><xsl:param name="{ > hostName ... Shortend it down... -- Invalid coercion: <images > xmlns:map="http://marklogic.com/xdmp/map"> <image> <name>97891 > 44027975/image001.eps</name> <id...</images> 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 > [email protected] > http://developer.marklogic.com/mailman/listinfo/general _______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
