Loading TOC...

MarkLogic 12 EA 2 Product Documentation
op:to-source

op:to-source(
   $importablePlan as item()
) as XQuerySource

Summary

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.

Example

(: 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"))
  

Example

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"))
  

Stack Overflow iconStack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.