Open Source Content Management System

MgdSchema file

  1. Naming Conventions
  2. Schema Structure
    1. Including Schemas
  3. Loading Schema Files

(see also: MgdSchema types in PHP)

Midgard objects are defined using the MgdSchema XML configuration file. Their classes are automatically registered for usage in applications and are described using MgdSchema file attributes and properties.

MidCOM components can supply their own MgdSchema files by using the PEAR Role_Mgdschema package.

Naming Conventions

Due to Zend limitations, type names should be in lowercase and use underscores as word separators. You should follow this convention if you want to define schema types for midgard-java and midgard-php applications.

There is an important change for midgard-php classes. Old classes are registered with Midgard prefix (e.g. MidgardArticle), while new classes are registered with underscores (e.g. midgard_article).

Temporary files with '.' or '#' prefixes, or with a '#' suffix will be ignored and warning messages will be printed to the log file or directly to the terminal window.

Schema Structure

Here's a simple example:

<?xml version="1.0" encoding="UTF-8"?>
<Schema xmlns="http://www.midgard-project.org/repligard/1.4">
    <include name="/full/path/wherever/even/from/schema/dir/file/xml" />

    <type name="midcom_core_group_virtual_db" table="midcom_group_virtual">
        <property name="id" type="integer" primaryfield="id" />
        <property name="component" type="text" />
        <property name="identifier" type="text" />
        <property name="name" type="text" />
    </type>
</Schema>

Including Schemas

Schemas can include other schemas and may even consist of included files only. Type definitions are not mandatory when you want to use more schemas.

All included schemas are "delayed" and parsed after the schema file which includes them is already parsed

<Schema xmlns="http://www.midgard-project.org/repligard/1.4">
    <include name="/full/path/wherever/even/from/schema/dir/file1/xml" />
    <include name="/full/path/wherever/even/from/schema/dir/file2/xml" />
    <include name="/full/path/wherever/even/from/schema/dir/file3/xml" />
    <include name="/full/path/wherever/even/from/schema/dir/file4/xml" />
</Schema>

All types which depend on other ones should be defined in included schemas. These may be located anywhere on the file system and should be referenced with their full path.

You should be warned when your schema tries to overwrite a Midgard type or any other type that is already defined

Loading Schema Files

When an application starts up, midgard-core parses the main schema file MgdObjects.xml which defines all legacy core types (like article, person, topic etc.).

To load a MgdSchema file, place it into your /usr/share/midgard/schema directory (this may be different if you chose another prefix during midgard-core compilation), and then edit your VirtualHost configuration to include it:

MidgardSchema /usr/share/midgard/schema/myschema.xml

Since Midgard 1.8 you can define schemas in the Unified configuration file. The MidgardSchema virtual host directive is not mandatory for shared schemas.

Designed by Nemein, hosted by Anykey