Thursday, 25 March 2010

MarkLogic: Loading and using XML Schemas (Part One)

These are some rough notes on techniques for using XML Schemas with MarkLogic.

Loading an XML Schema using cq:

The quickest way I've found to get a schema into your local MarkLogic instance is to copy your xsd file into your MarkLogic Docs folder (I also made a folder called schemas), then open a cq instance (or DQ if you prefer), select Schemas as your content source and use some XQuery like this:

Loading an XML Schema using XCC/J:

Another method would be to use XCC/J - I hope to write another post on this technique at another time with a more detailed example (note this method is untested at the time of writing):

After the cq process has been executed, running either:


Should show you the schema.

It's important to note that when MarkLogic loads schemas into its database, it will put in any values that have defaults on load. This caused some confusion when I was testing the "Schema Aware" aspects of the server. I added the following attribute to my schema's parent element:

Here's a very basic example of a schema layout:

Most of this information is available elsewhere, so this post will hopefully serve to pull a few pieces together in the interests of saving time.

Recommended reading:

No comments: