Search:

Apache » Lenya
project logo
  • Project
  • Developer
  • Community
  • Version 2.2
  • Version 2.0
  • Version 1.2
  • Version 1.2
    • Installation
      • Download
      • Subversion Access
      • Install Instructions
    • Tutorial
      • Introduction
      • 1. Understanding Lenya
      • 2. Installing Lenya
      • 3. Anatomy of the Pipeline
      • 4. Editing in Lenya
      • 5. Custom Navigation in Lenya
      • 6a. Mod Proxy and Lenya
      • 6b. Mod Proxy and Lenya
    • How-To
      • FAQ
      • New Publication
      • Deploy Publication
      • Look and Feel
      • Custom Resource Type
      • Adding Mime Types
      • Site Navigation
      • LDAP Authentication
      • CMS Menus
      • CMS Screens
      • Search Publications
      • External Data
      • Unit Tests
    • Components
      • Access Control
        • Basic Terms
        • Access Controllers
        • Access Controller Resolvers
        • Authenticators
        • Authorizers
        • Policies and Policy Managers
        • Accreditable Managers
        • SSL Encryption
      • Authoring
        • Adding a new document creator
        • Image Upload
        • OpenOffice
      • Deployment
        • Proxying
      • Editors
        • HTML Form Editor
        • HTML One Form Editor
        • Bitflux Editor
        • Kupu
        • Xopus
      • Layout
        • Navigation
        • XHTML templating
        • Serving static resources
        • Lenya Menubar
      • Publication
        • PageEnvelopeModule
        • Site tree
      • Resource Types
        • Resource Types
      • Revision Control
        • Revision Controller
        • RCML
        • Check In
        • Check Out
        • Revisions
        • Rollback
      • Repository
        • WebDAV Servers
      • Search
        • Searching with Lucene
      • URI Handling
        • URI Parametrizer
        • URI Scheme
        • Usecases
      • Asset Management
        • Asset Management
      • Link Management
        • Link Management
      • Meta Data
        • Meta Data Handling
      • Multilingual Documents
        • Multilingual Document Handling
      • Tasks
        • The Task Concept
        • Defining Tasks
        • The TaskAction
        • Scheduling a Task
        • Included tasks
          • AntTask
          • DefaultFilePublisher
          • StaticHTMLExporter
          • MailTask
        • Developing Tasks
      • Workflow
        • Terms
        • The State Machine
        • Configuration
        • Implementation
      • Site Management
        • Archive
        • Copy
        • Deactivate
        • Delete
        • Delete the trash
        • Move
        • Move Up/Down
        • Rename
        • Restore
    • Miscellaneous
      • Namespaces
      • Reserved Names
      • XInclude Processor
    • 1.2 API (Javadoc)

Current Event

Meeting Bad Säckingen 2009

Built with Apache Lenya

Resource Types (formerly known as Document Types)

Table of Contents
  • Basics
  • Adding a Resource Type to a Publication
    • Choose a Unique Resource Type Name
    • Providing a Sample XML Document
    • Providing an XML Structure Definition
    • Creating a Workflow Schema
    • The Resource Type Definition
    • Define the Mapping From URLs to Resource Types
    • Define a Custom Menubar
    • Presentation

Basics

A resource type defines a certain XML source format, together with processing options. It typically consists of

  • an XML structure definition (e.g., Relax NG)
  • a workflow schema,
  • some presentation pipelines,
  • some presentation XSLT stylesheets,
  • a Lenya menubar.

All of these can be shared between several resource types.

Adding a Resource Type to a Publication

Adding a custom resource type to your publication includes the following steps:

Choose a Unique Resource Type Name

You should choose a reasonable name for your resource type. In the examples, we use profile (page with information about a person).

Providing a Sample XML Document

If you want to enable users to create new resources belonging to your resource type, it is useful to provide a sample XML document. If you want to use the DefaultBranchCreator that ships with Lenya, you have to add the sample document because it is used as a template for creating new resources.

The sample document is placed in {publication}/config/doctypes/samples/. You can choose an arbitrary filename, but it is recommended to use the resource type name (e.g., profile.xml).

Providing an XML Structure Definition

This step is only needed if you want to edit resources with Lenya or validate them after they have been imported or manipulated. The type of the structure definition (XML Schema, Relax NG, ...) depends on the editor or validator you want to use. For instance, the BXE WYSIWYG editor requires a Relax NG document.

The structure definition document is placed in the directory {publication}/config/doctypes/schemas/. The name of the file is arbitrary, but it is recommended to use the resource type name (e.g., profile.rng).

Creating a Workflow Schema

If your resources should have a workflow, you have to add a workflow schema for your resource type as described in Workflow Configuration. A workflow schema can be shared between multiple resource types.

The Resource Type Definition

To assign the creator and the workflow schema to your resource type, declare it in {publication}/config/doctypes/doctypes.xconf:

<doc type="profile">
    <creator src="org.apache.lenya.cms.authoring.DefaultBranchCreator">
      <sample-name>profile.xml</sample-name>
    </creator>
    <workflow src="2stage.xml"/>
  </doc>

Define the Mapping From URLs to Resource Types

The resource type of a resource is determined based on the resource URL. This mapping happens in {publication}/parameter-doctype.xmap.

A typical approach to determine the resource type is to apply the SourceTypeAction on the source document:

<map:match pattern="*/**.html">
  <map:act type="sourcetype" src="content/{1}/{page-envelope:document-path}">
    <map:generate type="serverpages" src="../../config/parameters/default.xsp">
      <map:parameter name="value" value="{sourcetype}"/>
    </map:generate>
    <map:serialize type="xml"/>
  </map:act>
</map:match>

Another way is to return the resource type by just matching certain URLs:

<map:match pattern="*/profiles/*.html">
  <map:generate type="serverpages" src="../../config/parameters/default.xsp">
    <map:parameter name="value" value="profile"/>
  </map:generate>
  <map:serialize type="xml"/>
</map:match>

Define a Custom Menubar

If you want to use a custom menubar for your resource type, follow the guidelines on the page The Lenya Menubar. Typically, a menubar is shared between multiple resource types. Small customizations can be achieved with Java code in the menubar XSP.

To let the user create new resources using the DefaultBranchCreator, you have to add the following menu item:

<item uc:usecase="create" uc:step="showscreen" href="?doctype=profile"><i18n:text>New Document</i18n:text></item>

Presentation

To make your resources available as HTTP pages, you have to add the appropriate pipelines and XSLT stylesheets. In general, there are no restrictions.

If you derive your publication from the default publication, the pipelines have to be placed in {publication}/doctypes.xmap. The stylesheets are located in {publication}/xslt/ and are named {resource-type}2xhtml.xsl (e.g., profile2xhtml.xsl). The stylesheet is supposed to generate a valid XHTML fragment (in the XHTML namespace) with <div id="body"> as the document element.

Copyright © 1999-2009 The Apache Software Foundation. All rights reserved.