Chapter 14. Compact Node Definition Sequencer

14.1. Compact Node Definition Sequencer

The Compact Node Definition (CND) Sequencer processes JCR CND files to extract nodes and their definitions, inserting them into the repository usingJCR built-in types. The node structure generated by this sequencer is equivalent to the node structure used in /jcr:system/jcr:nodeTypes.

14.2. CND Sequencer Example

This sequencer generates a graph structure that corresponds to what can be found in the /jcr:system/jcr:nodeTypes subtree. As an example, the CND file below:
<mode = "http://www.modeshape.org/1.0">
	    
// My CND type
[mode:example] mixin
- mode:name (string) multiple copy
+ mode:child (mode:example) = mode:example version
The resulting graph structure (listed in theJCR document view) contains the node type information from the CND file above. Note that comments are not sequenced.
<mode:example jcr:primaryType="nt:nodeType"  
              jcr:mixinTypes="mode:derived"
              mode:derivedAt="2011-05-13T13:12:03.925Z"
              mode:derivedFrom="/files/docForReferenceGuide.xml"
              jcr:nodeTypeName="mode:example"
              jcr:supertypes="nt:base"
              jcr:isAbstract="false"
              jcr:isMixin="true"
              jcr:isQueryable="true"
              jcr:hasOrderableChildNodes="false">
  <nt:propertyDefinition jcr:name="mode:name"
                         jcr:autoCreated="false"
                         jcr:mandatory="false"
                         jcr:isFullTextSearchable="true"
                         jcr:isQueryOrderable="true"
                         jcr:onParentVersion="copy"
                         jcr:protected="false"
                         jcr:requiredType="STRING"
                         jcr:availableQueryOperators="= > >= < <= <> LIKE"
                         jcr:multiple="true" />
  <nt:childNodeDefinition jcr:name="mode:child"
                          jcr:autoCreated="false"
                          jcr:mandatory="false"
                          jcr:onParentVersion="VERSION"
                          jcr:protected="false"
                          jcr:requiredPrimaryTypes="mode:example"
                          jcr:defaultPrimaryType="mode:example"
                          jcr:sameNameSiblings="false" />                           
</mode:example>

14.3. Configuring a CND Sequencer

  1. Include the relevant libraries

    Include modeshape-sequencer-cnd-VERSION.jar in your application.
  2. Choose one of the following for sequencing configuration

    • Define sequencing configuration based on standard example provided in SOA-ROOT/eds/modeshape/resources/modeshape-config-standard.xml:
      <mode:sequencer jcr:name="CND File Sequencer" mode:classname="org.modeshape.sequencer.cnd.CndSequencer">
        <mode:description>
          Sequences CND files loaded under '/files', extracting the contained node type definitions.
        </mode:description>
        <mode:pathExpression>
          eds-store:default:/files(//(*.cnd[*]))/jcr:content[@jcr:data] => eds-store:default:/sequenced/cnd/$1
        </mode:pathExpression>
      </mode:sequencer>
    • Configure via org.modeshape.jcr.JcrConfiguration:
      JcrConfiguration config = ...
      
      config.sequencer("CND File Sequencer")
            .usingClass("org.modeshape.sequencer.cnd.CndSequencer")
            .loadedFromClasspath()
            .setDescription("Sequences CND files loaded under '/files', extracting the contained node type definitions.")
            .sequencingFrom("/files(//(*.cnd[*]))/jcr:content[@jcr:data]")
            .andOutputtingTo("/sequenced/cnd/$1");

    Note

    Refer to SOA-ROOT/eds/modeshape/resources/modeshape-config-standard.xml for more information.