op:to-source( $importablePlan as item() ) as XQuerySource
This function generates an XQuery source code representation of a plan from the JSON or JavaScript literal object representation of a plan that was exported by the op:export function.
For more information, see Exporting and Importing a Serialized Optic Query in the Application Developer's Guide
Parameters | |
---|---|
$importablePlan | The exported plan. This is generated by the op:export function. |
(: Generate the XQuery source for the exported plan, 'plan.json'. :) xquery version "1.0-ml"; import module namespace op="http://marklogic.com/optic" at "/MarkLogic/optic.xqy"; op:to-source(fn:doc("plan.json"))
xquery version "1.0-ml"; import module namespace op="http://marklogic.com/optic" at "/MarkLogic/optic.xqy"; let $plan := op:from-view("main", "employees") => op:select(("EmployeeID", "FirstName", "LastName")) => op:order-by("EmployeeID") => op:export() return op:to-source($plan) => op:from-view("main", "employees") =>op:select(("EmployeeID", "FirstName", "LastName")) =>op:order-by(op:col("EmployeeID"))