Loading TOC...


   $source-node as item(),
   $entity-type-name as xs:string
) as map:map


This function is deprecated and will not be supported in MarkLogic 11.
A utility function used by generated code to initialize an instance data structure with data common across all entities of a given type, such as a type indicator.

source-node The node to be initialized. This should be a source node of the form produced by es:init-source (XQuery) or es.initSource (JavaScript).
entity-type-name The entity type name expected by the caller.

Usage Notes

This function expects input in the form of a canonical instance, such as that produced by es:init-source. You will not usually call this function directly in your application code. It is used in code generated by Entity Services, such as an instance converter module.

You usually will not call this function outside of code generated by Entity Services. The generated code uses this function to add properties such as the $type property and, if appropriate, $ref property to an instance. This enables your customizations of the generated code to be independent of instance properties used internally by Entity Servcies.

See Also


xquery version "1.0-ml";
import module namespace es = "http://marklogic.com/entity-services"
  at "/MarkLogic/entity-services/entity-services.xqy";

let $raw := fn:doc('/es-gs/raw/1234.xml')
let $instance := es:init-instance(
  es:init-source($raw, 'Person'), 
return ($raw,$instance)

(: Return output similar to the following, assuming the document with
 : URI "/es-gs/raw/1234.xml" contains raw source data for extracting
 : instances for the "Person" entity type.
 : (<person>
 :    <pid>1234</pid>
 :    <given>George</given>
 :    <family>Washington</family>
 :  </person>,
 :  {"$type":"Person"})

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