Defining Node Types: CND

A Compact Node Type Definition (CND) specifies the structure and constraints for nodes of specific types in the Java Content Repository (JCR).

The full specification for the JCR CND format is available at
http://jackrabbit.apache.org/node-type-notation.html.

You can view the CND using the 'export CND' function in the console application's top menu. The node type definition determines which child nodes and properties a node can or must have, their data types, and whether they support multiple values. Every node type inherits from other node types, and all node types ultimately inherit from the base type nt:base.

A node type name includes a namespace and a local name. Similar to XML, the namespace is identified by a unique URL. At the top of a CND document, you declare namespace prefixes and associate them with their URLs. You can use multiple namespaces in a single CND file, but you must declare each one.

The following example shows a basic CND file:

<'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

Explanation of the example:

  1. Lines 1–4 declare the namespace prefixes and their associated URLs.
  2. [gettingstarted:basedocument] defines the node type gettingstarted:basedocument.
  3. This node type inherits from hippo:document, hippostd:publishableSummary, and hippostdpubwf:document.
  4. The orderable keyword allows child nodes to be ordered.
  5. The node types gettingstarted:textdocument and gettingstarted:newsdocument both inherit from gettingstarted:basedocument and hippostd:relaxed. The hippostd:relaxed type provides common residual item definitions.

You can define multiple node types in a single CND file. Child nodes can use types defined in the same namespace. In a CND file, you must define a node type before referencing it in other node type definitions.

CND files support additional rules:

  • You can mark a property or child node as mandatory.
  • Properties can be multi-valued, and child nodes can allow same-name siblings. Both cases use the multiple keyword, but the meaning differs.
  • You can define residual properties or child nodes, which apply to any property or child node name. Use * as the name to indicate a residual definition. If you provide a residual child node definition, the node can have multiple child nodes with different names—even without the multiple keyword—as long as each name is unique.
Share Feedback
Page: /build/content-repository/defining-node-types
Section: Build
Category *
Defining Nodetypes: CND | Bloomreach Content Documentation