close

Filter

loading table of contents...

Content Server Manual / Version 2310

Table Of Contents

4.2.1 Structure of Content Type Definitions

The basis for your content items in a CoreMedia CMS system is the XML file config/contentserver/doctypes/sample-doctypes.xml. It contains the root element <DocumentTypeModel> which serves as a container for the <DocType>, <XmlGrammar> and <XmlSchema> elements. It imports the grammar for CoreMedia rich text from the required-doctypes.xml file which is located in the framework/doctypes directory in cap-server.jar. The required-doctypes.xml contains the definitions which are essential for CoreMedia CMS. The next example shows a simple content type definition.

<ImportGrammar Name="coremedia-richtext-1.0"
      From="required-doctypes"/>

<DocType Name="article">
  <StringProperty Name="Author" Length="200"/>
  <StringProperty Name="Headline" Length="200"/>
  <DateProperty Name="Date"/>
  <XmlProperty Name="Summary" 
	Grammar="coremedia-richtext-1.0"/>
  <LinkListProperty Name="Images" LinkType="Image"/> 
</DocType>

<DocType Name="Image">
  <IntProperty Name="Width"/>
  <IntProperty Name="Height"/>
  <BlobProperty Name="Image" MimeType="image/*"/> 
</DocType>

Example 4.3. Example of a content type definition


Content type names

Every content type has a unique name, specified by the attribute Name. This name will be used by the Content Management Server to define unique data base identifiers like table names, primary key constraint names, foreign key constraint names and index names. The name has a maximum length of 11 characters, is not case-sensitive and can contain letters, numbers, underscore and dash but no umlauts or other special characters ("§", " &", ...). For a localization of content type and property names see Site Manager Developer Manual and Studio Developer Manual.

Caution

Caution

You are not allowed to use the following words for content type names:

  • Names of SQL commands.

  • Names which are reserved for CoreMedia as database table names:

  • BlobCodeTable, BlobData, Blobs,ChangeLog, CmGroups, CmLicenses, CmProcessorUsage,CmRules, CmUserGroup, CmUsers, Dictionary, EditorPreferences, FolderIndex, LinkChangeLog, LinkLists, ObservedValues, ObservedValueChangeLog, MaxIds, MaxMemberIds, MySQLBlobStore, Preferences, Query, QueryIdTable, ReplicatorIdTable, Resources, SgmlData, SgmlGrammar, SgmlText, System, Texts, TrashIdTable, WfDefinitions, WfMaxDeletedId, WfPendingSignals, WfProcessInstances, WfProcesses, WfTaskInstances, WfTasks, WfVariables

  • Names corresponding to the name scheme <doctype><digit><digit>"i"<char>*, where <doctype> stands for an already defined content type name, <digit> for a number and i<char>* for a word which begins with the letter "i".

If you have used content type names which exceeded the recommended length of 11 characters (which are longer than 15 characters to be exact) and you switch to another database you might exceed database limitations. In order to circumvent these problems there exists three attributes for the DocumentType element.

  • PkName: This attribute defines a name for the primary key constraint of the content type table.

  • ResourceFkName: This attribute defines a name for the foreign key constraint from the content type specific tables.

  • IndexName: This attribute defines the index name for columns of content type specific tables.

Example:

Your content type name is "ProductAttributes" (<DocumentType name="ProductAttributes">). This name contains 17 characters. The CoreMedia Server will extend this name by up to three characters to obtain unique database identifiers. In order to use your content type name furthermore you define unique names for the database using the attributes described above. Your new content type definition will look similar to the following example: <DocumentType name="ProductAttributes" PkName="pk_ProdAttr" ResourceFkName="fk_ProdAttr" IndexName="i_ProdAttr">

Three content types, Dictionary, Query and Preferences, are already defined in the required-doctypes.xml file. All types are essential for some components of CoreMedia CMS and must therefore neither be renamed nor deleted.

Defining the grammar

The <XmlGrammar> element with the attributes Name, Root, Parent and SystemId is used to refer to DTDs from XMLProperty elements. The following example defines the CoreMedia rich text grammar:

<XmlGrammar Name="coremedia-richtext-1.0"
      Root="div"
      PublicId="-//CoreMedia//DTD Rich Text 1.0//EN"
      SystemId="classpath:xml/coremedia-richtext-1.0.dtd"/>
Property Description

Name

The grammar name which you can use to reference the DTD

Root

The name of the XML root element

PublicId

The public identifier of the XML grammar

SystemId

A path that is either absolute or relative to $INSTALL_DIR which specifies the location of the XML grammar in the CoreMedia CMS server's file system or classpath. The SystemId can also be a URL from where the CoreMedia CMS server loads the XML grammar on startup.

Parent

CoreMedia CMS has an inheritance concept for XML grammars. If this attribute is set to the name of another XML grammar, the XML grammar may be used when overriding a property with the other XML grammar.

Table 4.5.  Attributes of XmlGrammar element


The following <XmlGrammar> elements are predefined:

  • coremedia-richtext-1.0, see RichtextDtd

  • coremedia-dictionary

  • coremedia-query, see QueryDtd

  • coremedia-struct-2008, see StructDtd

  • coremedia-preferences

The latter four belong to the Dictionary, Query, EditorPreferences, and Preferences content types respectively. The grammar coremedia-struct-2008 is also used frequently in CoreMedia Blueprint.

If you want to use XML Schemas instead of DTDs you can specify the <XmlSchema> element with the attributes Name, SchemaLocation, Language and Parent. The following example defines the grammar custom-schema with a schema file custom.xsd located in the package my.pkg, which is available in a JAR file deployed with the Content Server and any other server which needs to validate the XML as for example the Workflow Server if actions access properties using this grammar:

<XmlSchema Name="custom-schema" 
            SchemaLocation="classpath:my/pkg/custom.xsd 
                            http://www.w3.org/1999/xlink.xsd"
            Language="http://www.w3.org/2001/XMLSchema">

Example 4.4. Using XML Schemas


Property Description
Name

The name which you can use to reference the Schema

SchemaLocation

A path that is either absolute or relative to $INSTALL_DIR which specifies the location of the XML schema in the Content Server's file system or classpath. The SchemaLocation can also be a URL from where the CoreMedia CMS server loads the XML schema on startup. You can define multiple schemas, separated by white spaces.

Language

For example http://www.w3.org/2001/XMLSchema

Parent

Parent: CoreMedia CMS has an inheritance concept for XML schemas. If this attribute is set to the name of another XML schema, the XML schema may be used when overriding a property with the other XML schema.

Table 4.6.  Attributes of the XMLSchema element


You specify a DTD grammar or XML schema once in the content type declaration and can refer to it with the attribute Grammar in the XmlProperty element:

<DocType Name="Article">
    <StringProperty Name="Headline" Length="200"/>
    <XmlProperty    Name="Text"    
     Grammar="coremedia-richtext-1.0"/>
    <XmlProperty    Name="Summary" 
     Grammar="coremedia-richtext-1.0"/>
    <XmlProperty    Name="Comment" 
     Grammar="custom-schema"/>
</DocType>
Importing grammars and content types

You can import a grammar or schema into your content type file using the <ImportGrammar> element. The following example imports the "coremedia-richtext-1.0" grammar defined in the required-doctypes.xml file:

<ImportGrammar Name="coremedia-richtext-1.0"
From="required-doctypes"/>
Property Description

Name

The name of the grammar or schema you want to import.

From

The name of the XML file, where the grammar or schema is defined (without the file extension).

Table 4.7.  Attributes of the ImportGrammar element


You can also import content types that are defined in different content type files. This is necessary, if you want to use this content type as a parent or as a target of a LinkList property. The following example would import the type Article from the editorial-types.xml file.

<ImportDocType Name="Article"
From="editorial-types"/>

The attributes have the same meaning as for the ImportGrammar element.

Well-formedness of XML property values

When updating an XML property in content, well-formedness of XML must always be ensured. To this end, all XML data passed to the system must meet this requirement to be parsable, no matter if triggered via Unified API, serverimport tool, Studio Client, or other means. This also holds for XML containing special character entities defined by grammar coremedia-richtext-1.0.

The recommended way is to avoid custom entities. Example: instead of special character entity &nbsp; use unicode entity &#xA0; or UTF-8 code C2 A0.

If you still need to use these entities, explicitly refer to CoreMedia Rich Text DTD in XML:

<!DOCTYPE div PUBLIC "-//CoreMedia//DTD Rich Text 1.0//EN" "classpath:xml/coremedia-richtext-1.0.dtd">
    

Defining the DTD is not possible in XML for serverimport tool.

Upon ingestion of a new markup XML, all entities will be expanded by the parsing process. Entities (except pre-defined &amp;, &#gt;, and &lt;) will never be encountered again.

Search Results

Table Of Contents
warning

Your Internet Explorer is no longer supported.

Please use Mozilla Firefox, Google Chrome, or Microsoft Edge.