Defining Nodetypes: CND

A compact node type definition (CND) defines the structure of nodes of certain types. 

The complete specification of the compact node type definition of JCR (Jackrabbit) can be found at  http://jackrabbit.apache.org/node-type-notation.html.

The CND can be viewed from the console application by using the 'export CND' function in the top menu. The node type definition defines which items (child nodes and properties) a node may or must contain and of what type they must be. It also defines if multiple values of the item are allowed. A node type always inherits from other node types and all node types inherit from the base node type nt:base.

A node type name consists of a namespace and a local name. Just like with XML, the namespace is identified by a URL that must be unique. The namespace prefix is coupled to the namespace URL by a namespace declaration at the top of a CND document. Multiple namespaces can be used. All namespaces used must be declared.

Below you see a simple example of a CND.

<'gettingstarted'='http://www.onehippo.org/gettingstarted/nt/1.0'>
<'hippo'='http://www.onehippo.org/jcr/hippo/nt/2.0'>
<'hippostd'='http://www.onehippo.org/jcr/hippostd/nt/2.0'>
<'hippostdpubwf'='http://www.onehippo.org/jcr/hippostdpubwf/nt/1.0'>

[gettingstarted:basedocument] > hippo:document, hippostd:publishableSummary,
                                hippostdpubwf:document orderable

[gettingstarted:textdocument] > gettingstarted:basedocument, hippostd:relaxed

[gettingstarted:newsdocument] > gettingstarted:basedocument, hippostd:relaxed
  1. Lines 1-4 declare the namespace prefixes.
  2. The note type gettingstarted:basedocument is being defined (written between [ ]).
  3. it inherits from  hippo:documenthippostd:publishableSummary and  hippostdpubwf:document and (listed after >)
  4. child nodes will be orderable
  5. The type gettingstarted:textdocument inherits the publication workflow capabilities from the basedocument definition and inherits from  hippostd:relaxed which contains the most common residual item definitions

Multiple node types can be defined in a single CND file. Child nodes may be of a type defined in the same namespace. Note that in a CND file the definition of a node type has to be placed above any usage of the node type in other node types.

CND's can contain more rules. It is for example possible to define:

  • a property or child node to be mandatory.
  • a property may be multi-valued, while a child node may allow same-name siblings. Note that different meanings are both indicated by the same keyword: multiple.
  • A residual property or child node definition, which applies to a property or child node of any name. This is indicated by a * instead of the name. Note that if a residual child node definition is supplied, multiple child nodes of any name are allowed even without the keyword 'multiple', as long as the names are different.
Did you find this page helpful?
How could this documentation serve you better?
On this page
    Did you find this page helpful?
    How could this documentation serve you better?