MarkLogic Data Hub Service

Fast data integration + improved data governance and security, with no infrastructure to buy or manage.

Learn More


Stay On Top Of Everything MarkLogic

Be the first to know! News, product information, and events delivered straight to your inbox.

Sign Me Up


Stay On Top Of Everything MarkLogic

Be the first to know! News, product information, and events delivered straight to your inbox.

Sign Me Up


Stay On Top Of Everything MarkLogic

Be the first to know! News, product information, and events delivered straight to your inbox.

Sign Me Up

The MarkLogic Sample Authoring App for Word

by Pete Aven

The Authoring App in Action

The MarkLogic Authoring Sample App for Word lets authors enrich Word documents using Content Controls, associate and manage metadata with those Controls, as well as search and reuse existing Controls and their metadata in new Word documents.

The MarkLogic Sample Authoring App is built using the MarkLogic Toolkit for Word. Please install the Add-in and supporting XQuery library from the Toolkit to use this application. The Toolkit provides a guide for installation and comes with its own Sample Application. You can follow the guide instructions for installing this Sample App as well.

Getting Started

To get started using the Sample Application, you'll need to update 3 areas with the URL of your application. See the README, as well as the Sample Authoring App Developer's Guide, both included in the download for the application.

Following is an overview of the Sample Authoring App functionality. A developer's guide is included in the release so you can configure this application to meet your requirements. A 'files of interest' section is also included in the guide in case you just want to get in there and start hacking.


On this tab you have two sub-tabs to choose from, controls and boilerplate. The controls tab provides a palette of Content Controls to use. You can select the type of Control from the navigation bar on the controls tab. In the image we've selected Rich Text controls. The other Content Control types available are picture, calendar, drop down, and combo box.


Enrich Task Pane


You can enrich a document section by selecting text or sections of content in your Word document and then clicking the button to add a Rich Text Control around your selection.

Content Controls One

Or if you're authoring a new document, clicking a button without anything selected in the active document results in the control being added at the current cursor position.

Content Controls Two

The other controls add an image picker, calendar picker, or selectable lists of items. Only Rich Text controls can embed other controls and rich sections of content.

These controls are configurable. The amount of buttons you have for each control and their labels is determined by the configuration. For combo box and drop down controls, the selectable items for lists is also configurable. See the developer's guide for more detail. You can rename the controls, as well as create complex controls that embed other controls so an author could click a button that inserts a form of controls for entry if that's what you require.

The configuration is a simple XML file and it generates the HTML for the buttons on your palette as well as the associated JavaScript functions required for inserting the controls. The names you use for enrichment will be the values you use for Search once you've saved your document to MarkLogic Server.

By clicking on a control within an active document, the Properties section beneath the control palette helps to navigate the controls by providing information about the control you are currently authoring within. You'll see:

  • an icon for the type of control that is currently active in the document
  • the name of the title of the control
  • the name will be followed by the tag value for the control
  • if the control is embedded, a parent label is also provided to identify the parent control of the control that is active

This section also allows you to lock and unlock controls and their content. Here we see our Recommendation control is found within a Policy control and that the control and its contents are not currently locked.


Lock/Unlock Content Controls

The boilerplate tab provides buttons that will insert boilerplate Word documents saved in MarkLogic Server into the document actively being authored. The buttons are again configurable. The word, picture, and chart icons are provided as a way to cue authors into the types of documents they're inserting. The documents are inserted as XML, so they're appended to the active document at the current cursor position.

Note: You can think of this as inserting a .docx into a .docx, but the inserted document is not an embedded binary object.  The inserted XML becomes a natural part of the document being authored.

Boilerplate Tab


Each time you add a Content Control to your document, a custom XML metadata part is added to the .docx being authored. This custom metadata part is associated by id with the control you've added. On this tab you can edit the metadata values for associated controls.

The metadata pane provides a tree view hierarchy of the Content Controls within your document. By clicking on a label in the tree, the focus of the active document will go to that control in the document and the form for associated metadata will be displayed beneath the tree view. Edit values, and as you change fields, the values will be automatically saved to the metadata form.

For larger documents, navigating your controls by using the tree view may become tedious, so you can also click within a control in your active document. When you do this, the tree view focus will set to the associated control label in the tree and the associated metadata form will also be displayed.


Metadata Task Pane

You'll see that for this Sample, there are 3 types of metadata forms associated with the controls. We are also using Dublin Core metadata. This again, is configurable. You can use other XML for your metadata, and can even have a different custom XML metadata form for each control you define in the control palette. Please refer to the developer's guide included with the Sample Authoring App.

If you delete a control from the document, its associated metadata part is also removed from the .docx.


When you save a .docx to MarkLogic Server, it is automatically unzipped and made available for search and re-use. On this pane, you can search for text found within any Content Controls in documents saved in MarkLogic.


Search Task Pane

The results provide a count of search results as well as pagination.

For each result, for each control found that includes our search text, we see:

  • the document title (if present in the extracted document properties part) or the URI of the document in MarkLogic
  • the last modified date and last modified by for the source document
  • an icon informing which type of control our text was found within
  • the name of the control that includes our search text
  • a snippet of text, with our search text in bold
  • rollover of a snippet will display more text for the result
  • an insert button
  • an open button

Clicking insert will insert the Content Control into the active document at the current cursor position. The search result may have embedded controls as well. If any of the inserted controls had associated metadata parts in their source document in MarkLogic, those metadata parts are retained and added to the document being authored. You can view and edit any metadata values by examining them in the metadata tab.

By default, every control added to the document will have a custom metadata part associated with it, so if the source document didn't include metadata for the inserted control, the application associates a default metadata part. This is part of the configuration and detailed in the developer's guide.

Clicking open will open the source Word document from MarkLogic Server into Word on the client.

Search Filter

Finally, you can restrict searches through use of the filter tab. Click the drop down arrow to see a list of control labels you can select to apply to your search. This list is also configurable. To apply the criteria, click the filter button. You can close the filter selection and keep your filter applied.


Compare provides a search for metadata values found in custom XML parts that are within Word documents saved in MarkLogic Server. The drop down list, is a configurable list of values. When you select a value from the drop down, a search is performed in MarkLogic for any Word documents including the value in the drop down in a custom XML part within a Word document.


Compare Task Pane

The results returned are a slimmed down version of the Search tab results. You'll see:

  • the title or URI of the source document
  • the last modified date and last modified by for the source document
  • a compare button

Clicking compare opens the document into Word, alongside the document being authored, in Word's native merge functionality so authors can compare documents.


The Sample Authoring App is intended as a way to provide authors a way to enrich content in Word, as well as define and identify parts or sections of Word documents for search, re-use, auditing, and tracking.

By providing a way for authors to re-use sections of content across documents, identified by rich metadata, authors can then use MarkLogic to query where document components are being re-used. Also, if some document component includes text that needs to be updated across documents, the metadata can be used to run an update of components across all Word documents in MarkLogic that include those sections.

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


The commenting feature on this page is enabled by a third party. Comments posted to this page are publicly visible.