-
Notifications
You must be signed in to change notification settings - Fork 78
Loading schemas
Similar to non-REST modules, schemas are loaded by default via the App-Services server on port 8000. The Property reference defines the various properties for how a connection is made to 8000.
Note that when a new database is created, such as via mlNewProject
, it would point to the out-of-the-box Schemas database as its schemas database. Most of the time, you will want a database specific to your application for managing schemas. Thus, it is recommended to add a file to your src/main/ml-config/databases
directory that defines a schemas database to create. You can see this setup in this example project, which also shows how the content database is associated with the schemas database.
As of version 2.6.0, schemas can be loaded from child directories of src/main/ml-schemas
, and they can also be loaded into custom collections. See https://github.com/marklogic-community/ml-javaclient-util/wiki/Loading-files#specifying-collections-and-permissions for more information.
As of version 2.7.0, TDE templates no longer need to have a "tdex" or "tdej" suffix. Instead, any document with a URI starting with "/tde" will be put into the "http://marklogic.com/xdmp/tde" collection. Thus, for a schemas directory of src/main/ml-schemas
(which is the default location for schemas in an ml-gradle project), you would store your TDE templates in src/main/ml-schemas/tde
.
As of version 4.3.5, when loading schemas into MarkLogic version 10.0-9 or higher, TDE templates will be loaded via the new tde.templateBatchInsert function. This function handles validating all of your TDE templates at once, thus avoiding errors that can occur when templates are validated individually. However, if this function fails, the error is currently not being reported back to ml-gradle. You will instead see an error like this:
Server Message: Server (not a REST instance?) did not respond with an expected REST Error message
The underlying MarkLogic Java Client will soon be enhanced to provide the actual error message. As a workaround, you can use the tde.templateBatchInsert
function on your templates within qconsole to see the actual error message.
As of version 3.11.0, schemas can be loaded from database-specific paths, as defined in the Project layout page. Example:
databases
│ content-database.json
│ my-schemas-database.json
| my-other-schemas-database.json
└───my-schemas-database
└───schemas
my-schema.xsd
└───my-other-schemas-database
└───schemas
my-other-schema.xsd
Starting in release 3.13.0, TDE templates are validated by default. The property "mlTdeValidationEnabled" can be set to "false" to disable this behavior.
As of release 3.16.1, tokens will be replaced in schema files, just like they are for modules.