es:model-to-xml

es:model-to-xml(
   $model as map:map
) as element(es:model)

Summary

This function is deprecated and will not be supported in MarkLogic 11.
Serialize a basic model as an XML element.

Parameters
model A valid basic model.

Example

(: Round trip an XML model descriptor to a basic model and back to XML :)
xquery version "1.0-ml";
import module namespace es = "http://marklogic.com/entity-services"
  at "/MarkLogic/entity-services/entity-services.xqy";
es:model-to-xml(
  es:model-validate(
    <es:model xmlns:es="http://marklogic.com/entity-services">
      <es:info>
        <es:title>Example</es:title>
        <es:version>1.0.0</es:version>
      </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>
      </es:definitions>
    </es:model>
))

(: ==> The same XML model descriptor as used for input to es:model-validate :)
  

Example

(: Serialize a model stored in the database. :)
xquery version "1.0-ml";
import module namespace es = "http://marklogic.com/entity-services"
    at "/MarkLogic/entity-services/entity-services.xqy";

let $model-desc := fn:doc("/models/name.json")
return es:model-to-xml($model-desc)

(: ==> The model descriptor, serialized as XML. For an example, see the input
 :     to es:model-validate in the previous example. :)
  
Powered by MarkLogic Server | Terms of Use | Privacy Policy