Schema system

Contents

Define forms for management of structured content

Introduction

To facilitate creation of structured content Content Studio, Enonic XP ships with a high-level schema concept that requires no coding.

Each schema will produce a deterministic set of properties with valid values and indexing rules. Content can be submitted through both via UI, and API.

Forms

First and foremost, schemas define forms that can be edited through an administrative interface, typically Content Studio.

In addition to the user interface, schemas also have a back-end equivalent that can be used programmatically, for instance through the content API.

All forms are essentially compositions of various Input types.

Once a form is populated and submitted, the end-result will be a property structure that matches 1-1 with the schema definition. The property structure can then be persisted directly into the XP repository.

Forms can be declared statically with XML, using a format that looks like this:

<form>
  <input name="firstname" type="TextLine">
    <label>First Name</label>
  </input>
  <input name="lastname" type="TextLine">
    <label>Last Name</label>
  </input>
</form>

There are many types of forms, each with their specific purpose and options. The form implementation will control where and how end result is actually persisted.

The persisted output form the above form might look something like this:

{
  firstname: "Tom",
  lastname: "Cat"
}

Form grouping

In addition to input types, one may use sets to group form items to construct more advanced forms, and hence richer data models.

Use form items like Field sets (decorative only), Item sets, and Option sets for this purpose.

XML Schema Definition (XSD)

To simplify editing, an XSD is available.

Addf the following attributes to the first element of your XML file in order to enjoy validation while typing:

Not all editors support XSD validation
XSD attributes
xmlns="urn:enonic:xp:model:1.0"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:schemaLocation="urn:enonic:xp:model:1.0 https://raw.githubusercontent.com/enonic/xp/master/modules/core/core-api/src/main/resources/META-INF/xsd/model.xsd"

If added to a content type schema, it would look something like this:

Example when added to content type schema
<?xml version="1.0" encoding="utf-8"?>
<content-type
    xmlns="urn:enonic:xp:model:1.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="urn:enonic:xp:model:1.0 https://raw.githubusercontent.com/enonic/xp/master/modules/core/core-api/src/main/resources/META-INF/xsd/model.xsd">
  <display-name>Content type display name</display-name>

Contents

Contents