A document has been updated: http://cocoon.zones.apache.org/daisy/documentation/1505.html
Document ID: 1505 Branch: main Language: default Name: Introduction (unchanged) Document Type: Cocoon Document (unchanged) Updated on: 8/18/08 12:28:54 PM Updated by: Lukas Lang A new version has been created, state: draft Parts ===== Content ------- This part has been updated. Mime type: text/xml (unchanged) File name: (unchanged) Size: 5072 bytes (previous version: 37 bytes) Content diff: --- <html><body><p>TODO</p></body></html> +++ <html> +++ <body> +++ +++ <h1>Summary</h1> +++ +++ <p>This sample makes use of Cocoon components, built on top of Jackrabbit's +++ <a href="http://www.jcp.org/en/jsr/detail?id=170">JSR-170</a> (better known as +++ JCR - Java Content Repository) implementation. It shows, how to query, access +++ and write content.</p> +++ +++ <p>The Cocoon JCR (Java Content Repository) sample makes use of the +++ implementation independent abstraction layer, provided by the JCR block.</p> +++ +++ <h1>Documentation</h1> +++ +++ <p>The provided example allows three ways of accessing a content repository:</p> +++ +++ <ul> +++ <li>styled repository browsing</li> +++ <li>native repository access</li> +++ <li>XPath query</li> +++ </ul> +++ +++ <p>Furthermore, a basic write operation can be used.</p> +++ +++ <p>We will use the following components:</p> +++ +++ <ul> +++ <li>a TraversableGenerator for browsing</li> +++ <li>a SourceFactory for accessing the content repository</li> +++ <li>a JCRQueryTransformer for placing XPATH queries</li> +++ </ul> +++ +++ <p>Assuming, that our sample runs the following sitemap:</p> +++ +++ <pre><map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0"> +++ <map:pipelines> +++ <map:pipeline> +++ +++ <map:match pattern="populate"> +++ <map:generate src="populate.xml" /> +++ <map:transform type="cinclude" /> +++ <map:transform type="write-source" /> +++ <map:serialize> ... </map:serialize> +++ </map:match> +++ +++ <map:match pattern="browse/"> +++ <map:generate type="traversable" src="jcr://" /> +++ <map:transform src="dir2samples.xsl" /> +++ <map:serialize> ... </map:serialize> +++ </map:match> +++ <map:match pattern="browse/**/"> +++ <map:generate type="traversable" src="jcr://{1}/" /> +++ <map:transform src="dir2samples.xsl" /> +++ <map:serialize> ... </map:serialize> +++ </map:match> +++ <map:match pattern="browse/**"> +++ <map:generate src="jcr://{1}" /> +++ <map:transform src="dir2samples.xsl" /> +++ <map:serialize> ... </map:serialize> +++ </map:match> +++ +++ <map:match pattern="repository/"> +++ <map:generate type="traversable" src="jcr://" /> +++ <map:serialize type="xml" /> +++ </map:match> +++ <map:match pattern="repository/**/"> +++ <map:generate type="traversable" src="jcr://{1}/" /> +++ <map:serialize type="xml" /> +++ </map:match> +++ <map:match pattern="repository/**"> +++ <map:generate src="jcr://{1}" /> +++ <map:serialize type="xml" /> +++ </map:match> +++ +++ </map:pipeline> +++ </map:pipelines> +++ </sitemap> +++ </pre> +++ +++ <p>The first section, matching the <em>populate </em>pattern, does what the name +++ says: It writes sample content to the repository, which is then available +++ internally for browsing <em>jcr://</em> URIs.</p> +++ +++ <p>After pointing your browser to</p> +++ +++ <pre>http://localhost:8080/cocoon-jcr-sample/populate</pre> +++ +++ <p>and each of the response messages tell success, you can now access content. +++ To receive the repository root, point your browser to</p> +++ +++ <pre>http://localhost:8080/cocoon-jcr-sample/browse/</pre> +++ +++ <p>The <em>browse </em>section will be explained in detail. Let's first have a +++ look at parts of the Spring configuration file:</p> +++ +++ <pre> <bean name="org.apache.cocoon.generation.Generator/traversable" +++ class="org.apache.cocoon.generation.TraversableGenerator"> +++ </bean> +++ </pre> +++ +++ <p>The generator is used to generate content, read from a source, which allows +++ traversable operations. By this, locations and paths are represented as trees. +++ For more information about sources, see +++ <a href="http://excalibur.apache.org/apidocs/">Apache Excalibur JavaDoc</a>. +++ </p> +++ +++ <p>Next, we define a SourceFactory for <em>jcr://</em> URIs. This factory +++ represents the connector between a specified URI and the JCR repository, in this +++ case Jackrabbit. For more details on configuration, please see +++ <a href="daisy:1507">JCRSourceFactory</a>.</p> +++ +++ <pre> <bean name="org.apache.excalibur.source.SourceFactory/jcr" +++ class="org.apache.cocoon.jcr.source.JCRSourceFactory"> +++ <property name="repository" ref="javax.jcr.Repository" /> +++ <property name="credentials"> ... </property> +++ <property name="typeInfos"> ... </property> +++ </bean> +++ </pre> +++ +++ <p>As you now know, how resources are resolved, we understand, why we can +++ forward requests to the predefined generator.</p> +++ +++ <pre> <map:match pattern="browse/**"> +++ <map:generate src="jcr://{1}" /> +++ <map:transform src="dir2samples.xsl" /> +++ <map:serialize> ... </map:serialize> +++ </map:match> +++ </pre> +++ +++ <p>Pointing your browser at</p> +++ +++ <pre>http://localhost:8888/cocoon-jcr-sample/browse/cocoon/sitemap</pre> +++ +++ <p>the generator will resolve the JCR path <em>jcr://cocoon/sitemap</em>, using +++ the referenced JCRSourceFactory.</p> +++ +++ <h1>Configuration</h1> +++ +++ <h1>Further reading</h1> +++ +++ </body> +++ </html>