<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ ModeShape (http://www.modeshape.org)
  ~
  ~ See the COPYRIGHT.txt file distributed with this work for information
  ~ regarding copyright ownership.  Some portions may be licensed
  ~ to Red Hat, Inc. under one or more contributor license agreements.
  ~ See the AUTHORS.txt file in the distribution for a full listing of 
  ~ individual contributors.
  ~
  ~ ModeShape is free software. Unless otherwise indicated, all code in ModeShape
  ~ is licensed to you under the terms of the GNU Lesser General Public License as
  ~ published by the Free Software Foundation; either version 2.1 of
  ~ the License, or (at your option) any later version.
  ~
  ~ ModeShape is distributed in the hope that it will be useful,
  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  ~ or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
  ~ for more details.
  ~
  ~ You should have received a copy of the GNU Lesser General Public License
  ~ along with this distribution; if not, write to:
  ~ Free Software Foundation, Inc.
  ~ 51 Franklin Street, Fifth Floor
  ~ Boston, MA  02110-1301  USA
  -->
<!DOCTYPE preface PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"	[
<!ENTITY % CustomDTD SYSTEM "../../custom.dtd">
%CustomDTD;
]>
<chapter id="cnd-sequencer">
  <title>Compact Node Type (CND) Sequencer</title>
  <para>
  	This sequencer processes JCR Compact Node Definition (CND) files
		to extract the node definitions with their property definitions, and inserts these into the repository using JCR built-in types.
	The node structure generated by this sequencer is equivalent to the node structure used in <code>/jcr:system/jcr:nodeTypes</code>.
  </para>
  
      <sect1>
        <title>Example</title>
	    <para>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:
	    </para>
	    <programlisting><![CDATA[
<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
]]></programlisting>
	    <para>
				The resulting graph structure (listed in the JCR document view) contains the node type information from the 
				CND file above.  Note that comments are not sequenced.
	    </para>
	    <programlisting language="XML" role="XML"><![CDATA[
<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>
]]></programlisting>
	<para>
		This sequencer can be added to the repository configuration like so:
	</para>
	<programlisting language="JAVA" role="JAVA"><![CDATA[
JcrConfiguration config = ...

config.sequencer("CND Sequencer")
      .usingClass("org.modeshape.sequencer.cnd.CndSequencer")
      .loadedFromClasspath()
      .setDescription("Sequences CND files to extract the node type definitions")
      .sequencingFrom("//(*.cnd[*])/jcr:content[@jcr:data]")
      .andOutputtingTo("/nodeTypes/$1");
]]></programlisting>
	</sect1>  	 
</chapter>
