close

Filter

Importer Manual / Version 2307

Table Of Contents

4.1.4 Field Elements

CoreMedia CMS does not run without specifying document types and their fields (see the Content Server Manual), for example

<XmlGrammar Name="coremedia-richtext-1.0" Root="div" 
SystemId="lib/xml/coremedia-richtext-1.0.dtd"/>
<DocType Name="Text">
    <StringProperty     Name="Headline" Length="200"/>
    <XmlProperty   Name="Text" Grammar="coremedia-richtext-1.0"/>   
    <IntProperty        Name="Priority"/>
    <StringProperty     Name="Source" Length="20"/>
    <DateProperty       Name="AutoDeletedate"/>
    <DateProperty       Name="AutoPdate"/>
    <LinkListProperty   Name="Image" LinkType="Image"/>
</DocType>

Example 4.3. Document type


If the property import.enforceCompleteVersion in the configuration file of the importer is set to "true" (default), then the values for all fields must be provided for an import of a document of this type. For each document property (StringProperty, XmlProperty, ...), there must be a corresponding XML element (string, text, ...). If one declared field is missing an error message is generated, and if there are two values for one field, the first is overwritten by the last.

If the property import.enforceCompleteVersion in the configuration file of the importer is set to "false", it is not necessary to provide all elements. See the Administrator Manual for a description of the property.

Before the format of each field element is described in detail, the following example shows a typical document of the above document type:

<document name="MyDocument" id="1" type="Text" 
  path="/News/Financial/">
  <version number="1">
     <string name="Headline" value="New Market on descent"/>
     <text name="Text">
       <div>
         <p>Nemax closed with losses.</p>
       </div>
     </text>
     <integer name="Priority" value="42"/>
     <string name="Source" value="Stockresearch"/>
     <date name="AutoDeletedate" 
           date="2001-01-29" time="00:00"
           timezone="Europe/Berlin" />
     <date name="AutoPdatum" 
           date="2001-01-22" time="22:30"
           timezone="Europe/Berlin"/>
     <linklist name="Images"><link idref="pic1"/></linklist>
  </version>
</document>

Example 4.4. A document


The order of the field elements in the example corresponds to the order of the fields in the definition of the document type Text, but this is not required, as any order can be used.

CoreMedia XML supports the document fields of type structured and unstructured text, number, date, blob and linklist. These are now described in detail. All field elements have an attribute name for the document field. The attribute is not explicitly listed below.

<text>

Corresponds to an <XmlProperty> in the document type definition. The CoreMedia DTD allows PCDATA as content, the format of the <text> content deviates at this point from the DTD: the content of <text> must conform to the grammar DTD defined for the field.

<string>

Corresponds to a <StringProperty> in the document type definition. The attribute value holds the string content.

<string name="Heading" value="New market on descent/>

<integer>

Corresponds to an <IntProperty> in the document type definition. The attribute value contains the number.

<integer name="Priority" value="42"/>

<date>

Corresponds to a <DateProperty> in the document type definition. In addition to the name attribute, there are three further attributes:

  • date: the date must be entered in the format yyyy-mm-dd, such as 2001-11-06

  • time: the time must be entered in the format hh:mm, such as 09:00 or hh:mm:ss, such as 23:59:59

  • timezone: the format corresponds to the Java 2 API (java.util.TimeZone), such as Europe/Berlin or GMT.

All three attributes are optional. If date is left out, the whole date is undefined. On the other hand, the default values 00:00 and java.util.TimeZone.getDefault() are used for time and timezone, resp.

<date name="AutoPdate" date="2001-01-01" time="12:15" timezone="Europe/Berlin"/>

<blob>

Corresponds to a <BlobProperty> in the document type definition. The element has two further attributes:

  • mimetype: the MIME type must match the MIME type defined in the corresponding <BlobProperty> element in the definition of the document type. Wildcards, like image/* are not allowed.

  • href: the URL of a blob. It is given either absolute or relative to the value of the xml:base attribute of the <coremedia> element.

<blob name="onlineImage" mimetype="image/jpeg" href="chart.jpg"/>

<linklist>

Corresponds to a <LinkListProperty> in the document type definition. It can have both <document> and <link> child elements. <document> children are imported like other <document> elements. The empty element <link> has an attribute idref with an ID value. The consistency rules given above apply to this idref attribute. All documents of a <linklist> must have a type that corresponds to the type specified with the LinkType attribute of the corresponding <LinkListProperty>.

<linklist name="Images"><link idref="pic1"/></linklist>

The content of <text> is included in two ways:

  • Embedded text

  • Place the content in the <text> element.

  • Example:

  • <text name="Text"> <div> <p>...Flowing text...</p> </div></text>

  • A separate XML resource

  • The content is stored in a separate resource and referred to by URL given in the href attribute. The XML in the resource must be well-formed. The root element depends on the DTD specified for the field type. The URL in the href attribute is relative to the main XML document containing the <text> element, or absolute. If the resource is a file, do not store the file in the importer inbox directory when the default SubDirGenerator is configured in cm-xmlimport.properties. Otherwise, the importer will try to import the file and fail.

  • Example:

  • <text name="Text" href="../href/text.txt"/>

The importer selects the embedded content if <text> element contains embedded content and a href attribute.

Links in XML fields

You can define XML fields that conform to any DTD. To link to documents from this XML fields use the attribute xlink:href. The attribute value must start with the prefix coremedia:///cap/resources/ followed by an internal or target id as shown below:

<text name="Text">
	<div><p>See<a xlink:href="coremedia:///cap/resources/info">info
	</a></p></div>
</text>

Example 4.5. Example for the xlink:href attribute


This example contains a link to a document with the internal id info. The internal id must not contain a "/" character. To link to a field of a document append a "/" character and the name of the field.

<text name="Text">
	<div><p>See<a xlink:href="coremedia:///cap/resources/info/xml">
	info</a></p></div>
</text>

Example 4.6. Example for a property link


This example contains a link to the field xml in the document with the internal id info. The field name may not contain a "/" character. If you use a link in an <img> tag, the link must point to the BlobProperty of the document. The following example contains links with target ids:

<text name="Text">
	<div><p>see
	<a xlink:href="coremedia:///cap/resources/target:2468">info1
	</a>and
	<a xlink:href="coremedia:///cap/resources/target:1234/xml">
	info2</a>
	</p></div>
</text>

Example 4.7. Example for links with target ids


XML fields that conform to the now deprecated coremedia-sgmltext.dtd may link to documents with the elements <HOX.LINK> and <HOX.IMAGE> as shown in the following example:

<text name="Sgmltext">
	<ROOT> <P>See<HOX.LINK ID="info">info</HOX.LINK>
	</P></ROOT>
</text>

Example 4.8. Example for the HOX.LINK element


Both internal and target ids can be used in the attribute ID.

Search Results

Table Of Contents
warning

Your Internet Explorer is no longer supported.

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