Your function is returning multiple nodes and it is declared as only returning 
one.


-----------------------------------------------------------------------------
David Lee
Lead Engineer
MarkLogic Corporation
[email protected]
Phone: +1 812-482-5223
Cell:  +1 812-630-7622
www.marklogic.com<http://www.marklogic.com/>


From: [email protected] 
[mailto:[email protected]] On Behalf Of sini narayanan
Sent: Thursday, November 22, 2012 12:42 PM
To: MarkLogic Developer Discussion
Subject: [MarkLogic Dev General] Invalid coercion

Hi,

I'm getting the following error:
[1.0-ml] XDMP-AS: (err:XPTY0004) local:insert-element($data) -- Invalid 
coercion: (<equipment equipmentLabel="Garden" equipmentID="PARC"/>, <equipment 
equipmentLabel="AirConditioned Room" equipmentID="CLIM_CHB"/>, <equipment 
equipmentLabel="Conference Room" equipmentID="SALLE_REUN_CONFR"/>, ...) as 
node()
I have created a function which return a node as below

declare function local:insert-element($data) as node() {

    let $EquipmentMap   := fn:doc("/GA/equipmentMap.xml")
    for $content in $EquipmentMap//map:entry
    let $keys := $content/@key
    let $label := $content/map:value/text()
    where $data/etData/etField//fieldValue[@fieldCode eq $keys]
     return
        <equipment equipmentLabel="{$label}" equipmentID="{$keys}"/>
};

The method is called inside the doc insert command:

let $create-od := xdmp:document-insert($doc-name-od,
        <datasheet datasheetType="objectiveData">
        <equipments>{local:insert-element($data)}</equipments>
        </datasheet>,
        xdmp:default-permissions(),
        xdmp:default-collections(), 10)

And by $data is fn:doc("/xmlName.xml")/test


Is there something wrong 'm doing. Please help.

Thanks
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to