es:init-source( $source-nodes as item()*, $entity-type-name as xs:string ) as item()*
This function is deprecated and will be removed in a future release.
Return the root node of an entity instance or document.
This function is meant for use in code generated by Entity Services.
You will not usually call this function outside of code generated by
Entity Services. The generated code uses this function to normalize
references to incoming source data to simplify the code. For example,
when you generate an instance converter module, the
extract-instance-T
function for some entity type
T
calls this function to normalize its input, which
might be an XML element node, a JSON object node, or a document node.
xquery version "1.0-ml"; import module namespace es = "http://marklogic.com/entity-services" at "/MarkLogic/entity-services/entity-services.xqy"; let $node := fn:doc('/es-gs/raw/1234.xml') return ($node, xdmp:describe($node), $node, xdmp:describe(es:init-source($node, 'Person'))) (: Assuming the input document node contains raw source to be used in : constructing a Person entity instance, this example returns the : following. Note that the input data type is a document node, but the : output data type is an element node. : : ( <?xml version="1.0" encoding="UTF-8"?> : <person> : <pid>1234</pid> : <given>George</given> : <family>Washington</family> : </person>, : fn:doc("/es-gs/raw/1234.xml"), : fn:doc("/es-gs/raw/1234.xml")/person ) :) (: Returns the following JSON array: ["1", "2"] :)