Define Entity Type

Define an entity type
define-entity-type name () documentation-string [({slots}*)] {options}* {form}*

Defines a new entity type with the given name and makes it available for all sites. The definition replaces an eventual previous definition of the entity type.

The new entity type is listed in the menu of the New Entity dialog. The entity can be referenced in any content of the site using an entity reference such as &name; where the name equals the label from the entity definition.

The body of the definition typically contains one or more forms that generates a value for the entity. The result value should be a DOM node or nodelist.

The optional slots holds information used when generating a value for the entity. The syntax is as for slots in CLOS Class definitions.

The options are keyword/value lists that specifies initial arguments for the entity. The following options have special meaning:

namespace
String that labels an XML namespace (required).
load
Function that uses DOM to load the slots of the entity based on the content of a element. It takes the entity and an element as argument.
store
Function that uses DOM to store the slots of the entity into the content of an element. It takes the entity and an element as argument.
editor
Function that opens an editor to modify the entity. It takes the entity as argument.
transformation
An XSLT stylesheet that specifies a default transformation of the entity value into XHTML. The value can be an inline XML marked section, a variable with an XSLT stylesheet, or a reference to an entity with an XSLT stylesheet as value.
Side effects: Changes or establishes the entity type.

(entities::define-entity-type markup ()  "Arbitrary XML markup"  (:namespace "http://www.in-progress.com/2000")  (with-open-dom (content (entity))   (dom:child-nodes (dom:document-element content))))

(entities::define-entity-type db ()  "Formatting 'record' elements in the entity file, where each contains a 'first' and 'last' element wihh text such as the first and last name of a person"  (:namespace "http://www.in-progress.com/2000/db")  (:transformation
  <![[xsl:xsl-transform xmlns:xsl="http://www.w3.org/1999/XSL/xsl-transform">
   <xsl:template match="self::record">
   <tr>
    <td><xsl:value-of select="first"/></th>
    <td><xsl:copy-of select="last/text()"/></td>
    <xsl:apply-templates/>
   <tr>
  </xsl:template>
 <xsl:xsl-transform>]]>)
 (with-open-dom (content (entity))
  (dom:child-nodes (dom:document-element content))))

Related: define-entity

Interaction Developer Reference


This site is enhanced with Interaction.