es:init-instance( $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.
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.
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'), '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: Get the most useful answers to questions from the MarkLogic community, or ask your own question.