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