
op:col( [$plan as map:map], $colName as string ) as map:map
This method identifies a column, where the column name is unique. A qualifier on the column name isn't necessary (and might not exist). In positions where only a column name can appear, the unqualified column name can also be provided as a string. Qualified column names cannot be provided as a string.
| Parameters | |
|---|---|
| $plan | The Optic AccessorPlan created by op:from-view, op:from-triples, or op:from-lexicons. |
| $colName | The name of the column. |
xquery version "1.0-ml";
import module namespace op="http://marklogic.com/optic"
at "/MarkLogic/optic.xqy";
let $resource := op:prefixer("http://dbpedia.org/resource/")
let $foaf := op:prefixer("http://xmlns.com/foaf/0.1/")
let $onto := op:prefixer("http://dbpedia.org/ontology/")
let $person := op:col("person")
return op:from-triples((
op:pattern($person, $onto("birthPlace"), $resource("Brooklyn")),
op:pattern($person, $foaf("name"), op:col("name"))))
=> op:result()
xquery version "1.0-ml";
import module namespace op="http://marklogic.com/optic"
at "/MarkLogic/optic.xqy";
let $employees := op:from-view("main", "employees")
let $expenses := op:from-view("main", "expenses")
let $totalexpenses := op:col("totalexpenses")
return $employees
=> op:join-inner($expenses, op:on(
op:view-col("employees", "EmployeeID"),
op:view-col("expenses", "EmployeeID")))
=> op:group-by(op:view-col("employees", "EmployeeID"),
("FirstName", "LastName",
op:view-col("expenses", "Category"),
op:sum($totalexpenses,
op:view-col("expenses", "Amount"))))
=> op:order-by(op:view-col("employees", "EmployeeID"))
=> op:result()
Stack Overflow: Get the most useful answers to questions from the MarkLogic community, or ask your own question.