Loading TOC...

MarkLogic Server 11.0 Product Documentation
es.modelFromXml

es.modelFromXml(
   model as Node
) as Object

Summary

This function is deprecated and will be removed in a future release.
Create a basic model from an XML model descriptor, without validating the input descriptor for correctness.

Parameters
model A valid XML model descriptor, as an es:model element or as a document with an es:model element as its root.

Usage Notes

This function converts the XML representation of a model descriptor into the in-memory representation of a basic model. This function does not validate the XML, so it is best suited for faster conversion of a descriptor known to be valid. If you supply an invalid model descriptor, the resulting basic model will also be invalid and may result in problems when you try to use other Entity Services APIs on the model.

Use es.modelValidate to validate the descriptor while creating a basic model

There is no equivalent to this function for JSON because the JSON representation of a valid model descriptor is identical to the corresponding basic model.

See Also

Example

// Create basic model from an XML model descriptor stored in the database.
const es = require('/MarkLogic/entity-services/entity-services');

const modelDesc = fn.doc('/descriptors/name.xml');
es.modelFromXml(modelDesc);

/* Result: A basic model, as an Object. For example:
{ "info": {
    "title": "Example",
    "version": "1.0.0"
  },
  "definitions": {
    "Name": {
      "properties": {
        "first": { "datatype": "string" },
        "middle": { "datatype": "string" },
        "last": { "datatype": "string" }
      },
      "required": [ "first", "last" ]
    }
  }
}
*/
  

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