Hello there,
I am trying to use xquery:eval method supplying bindings as map, and following the example on the website where the bindings are supplied as a map. However, when I run the following query, I get the error "Items of type map(*) cannot be atomized". What am I doing wrong?
(:Filter out the required diagrams from $diagrams:) declare variable $depotConstraint external := "OC"; declare variable $resConstraint external := "NIL"; declare variable $lowerDiagNoConstraint external := "NIL"; declare variable $upperDiagNoConstraint external := "NIL";
(:Bindings for diagramSelectionCoR.xq:) declare variable $bindings := map { xs:QName("depotConstraint") : $depotConstraint, xs:QName("resConstraint") : $resConstraint, xs:QName("loweDiagNoConstraint") : $lowerDiagNoConstraint, xs:QName("upperDiagNoConstraint") : $upperDiagNoConstraint};
declare variable $diagramSelection := xquery:eval(file:read-text("D:\XQuery\VPExchange Queires\diagramSelectionCoR.xq", $bindings));
$diagramSelection
For completeness, the query being loaded in the $diagramExchange "xquery:eval" is:
declare default element namespace "http://www.scfy.com/TTVP_Interface";
declare variable $date := "2017-07-10"; declare variable $daysRun := 3; declare variable $diagrams := diagramExchange/unitDiagramList/unitDiagram[@startdate<=$date][@enddate>=$date][substring(@daysrun,$daysRun,1)="Y"];
declare variable $depotConstraint external := "NIL"; declare variable $resConstraint external := "NIL"; declare variable $lowerDiagNoConstraint external := "NIL"; declare variable $upperDiagNoConstraint external := "NIL";
declare variable $depots := tokenize($depotConstraint," "); declare variable $resources := tokenize($resConstraint," "); declare variable $lowerDiagNo := tokenize($lowerDiagNoConstraint," "); declare variable $upperDiagNo := tokenize($upperDiagNoConstraint," ");
declare function local:begin($diagrams, $index) { local:applyDiagStartFilter($diagrams,$index) };
(: Chain of responsibility pattern used here : once one function exits, passes to the next:)
declare function local:applyDiagStartFilter($diagrams, $index) { let $diagNo := $lowerDiagNo[$index] return if($diagNo = "NIL") then (local:applyDiagEndFilter($diagrams, $index)) else (local:applyDiagEndFilter($diagrams[@id >= $diagNo cast as xs:integer], $index)) };
declare function local:applyDiagEndFilter($diagrams, $index) { let $diagNo := $upperDiagNo[$index] return if($diagNo= "NIL") then (local:applyResFilter($diagrams, $index)) else (local:applyResFilter($diagrams[@id <= $diagNo cast as xs:integer], $index)) };
declare function local:applyResFilter($diagrams, $index) { let $res := $resources[$index] return if($res = "NIL") then (local:applyDepotFilter($diagrams, $index)) else (local:applyDepotFilter($diagrams[res/@id = $res], $index)) };
declare function local:applyDepotFilter($diagrams, $index) { let $depot := $depots[$index] return if($depot = "NIL") then ($diagrams) else ($diagrams[depot/@id = $depot]) };
for $depot in $depots count $count return local:begin($diagrams, $count)