Loading TOC...

es:instance-converter-generate

es:instance-converter-generate(
   $model as map:map
) as document-node()

Summary

Generate an XQuery library module containing stub code for converting source data to entity instances.

Parameters
$model A valid basic entity model.

Usage Notes

The output of this function is an XQuery library module containing boilerplate code you can customize for ingestion scenarios. You must insert the generated module into your modules database to use it.

The generated module contains code to get you started on a data integration pipeline. The module also contains comments that explain the default code and provide tips for customization.

The generated code is runnable out-of-the-box, but the default implementation is suitable for only those entity instances that already conform to the canonical representation. Any transform from source systems should be implemented by customizing the generated functions.

See Also

Example

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

es:instance-converter-generate(
  es:model-from-xml(
    <es:model xmlns:es="http://marklogic.com/entity-services">
      <es:info>
        <es:title>Example</es:title>
        <es:version>1.0.0</es:version>
        <es:description>ES Examples</es:description>
      </es:info>
      <es:definitions>
        <Name>
          <es:properties>
            <first><es:datatype>string</es:datatype></first>
            <middle><es:datatype>string</es:datatype></middle>
            <last><es:datatype>string</es:datatype></last>
          </es:properties>
          <es:required>first</es:required>
          <es:required>last</es:required>
        </Name>
        <Person>
          <es:properties>
            <id><es:datatype>int</es:datatype></id>
            <name><es:ref>#/definitions/Name</es:ref></name>
            <bio><es:datatype>string</es:datatype></bio>
            <rating><es:datatype>float</es:datatype></rating>
            <phone>
              <es:datatype>array</es:datatype>
              <es:items><es:datatype>string</es:datatype></es:items>
            </phone>
          </es:properties>
          <es:primary-key>id</es:primary-key>
          <es:required>id</es:required>
          <es:required>name</es:required>
        </Person>
      </es:definitions>
    </es:model>
))

(: ==> An XQuery library module containing functions such as
 :     example:extract-instance-Name, example:extract-instance-Person,
 :     example:instance-to-canonical-xml, and example:instance-to-envelope. :)
  

Comments

    Powered by MarkLogic Server 7.0-4.1 and rundmc | Terms of Use | Privacy Policy