Search:

Apache » Lenya
project logo
  • Project
  • Developer
  • Community
  • Version 2.2
  • Version 2.0
  • Version 1.2
  • Version 2.0
    • FAQs
    • Installation
      • Download
      • Subversion Access
      • Install Instructions
    • Tutorials
      • Create a Publication
      • Create a Resource Type
        • Declaration
        • Creation
        • Presentation
        • Editing (One-Form)
        • Editing (BXE)
      • Implement a Usecase
        • Prerequisites
        • The Usecase
      • Setting up Eclipse
      • Proxying
        • Proxying
        • mod_proxy
        • mod_proxy_ajp
      • Best Practises
      • Production Checklist
      • Writing Tests
    • Concepts
      • Publication
      • Working with Documents
      • Authoring and Live mode
      • WYSIWYG
    • Technical Reference
      • Overview of Lenya Sitemaps
      • Repository
      • Access Control Specification
      • Usecase Framework
        • Overview
        • AbstractUsecase
      • Publications
        • Configuration
        • Publication Templating
      • Resource Types
      • Modules
      • Meta data
      • Protocols
        • lenya Protocol
        • lenya-document Protocol
        • site Protocol
        • lenyadoc Protocol
        • fallback Protocol
      • URLs and Links
        • URL Mapping
        • Link Management
    • Core API
    • Core Modules
      • ac
        • Overview
        • API
      • acusecases
        • Overview
        • API
      • administration
        • Overview
        • API
      • cache
        • Overview
        • API
      • janitor
        • Overview
        • API
      • ldap
        • Overview
        • API
      • linking
        • Overview
        • API
      • observation
        • Overview
        • API
      • properties
        • Overview
        • API
      • sitemanagement
        • Overview
        • API
      • templating
        • Overview
        • API
      • usecase
        • Overview
        • API
      • workflow
        • Overview
        • API
    • Standard Modules
      • blog
        • Overview
        • API
      • bxe
        • Overview
      • cforms
        • Overview
        • API
      • collection
        • Overview
        • API
      • contactform
        • Overview
        • API
      • development
        • Overview
        • API
      • editors
        • Overview
        • API
      • export
        • Overview
        • API
      • fckeditor
        • Overview
        • API
      • kupu
        • Overview
        • API
      • languageselector
        • Overview
      • lenyadoc
        • Overview
        • API
      • linkcheck
        • Overview
        • API
      • links
        • Overview
        • API
      • lucene
        • Overview
        • API
      • migration
        • Overview
        • API
      • navigation
      • neutron
        • Overview
      • news
        • Overview
        • API
      • notification
        • Overview
        • API
      • opendocument
        • Overview
        • API
      • prettyprinting
        • Overview
      • profiling
        • Overview
      • resource
        • Overview
        • API
      • simplesite
        • Overview
        • API
      • sitetree
        • Overview
        • API
      • sourcerepository
        • Overview
        • API
      • svg
        • Rounded Corners
        • Resizing Images
        • API
      • tinymce
        • Overview
        • API
      • usecasedocument
        • Overview
        • API
      • webdav
        • Getting started
        • Monitoring
        • WebDAV Servers
        • API
      • xhtml
        • Overview
        • API
      • xopus
        • Overview

Current Event

Meeting Bad Säckingen 2009

Built with Apache Lenya

Creating a Resource Type, Part 4: Editing

Table of Contents
  • Adding the Relax NG Schema
  • Enabling the Source Editor

In this section we make our person documents editable.

Adding the Relax NG Schema

When we allow to edit documents, we have to make sure that the resulting XML conforms to the FoaF specification. For this purpose we provide a Relax NG schema for the FoaF person XML format. Here's a simple schema, created with Trang, which - according to the resource type declaration - has to be located at $MODULE_HOME/resources/schemas/foaf.rng:

<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0"
  xmlns:foaf="http://xmlns.com/foaf/0.1/"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
  datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
  <start>
    <element name="rdf:RDF">
      <element name="foaf:Person">
        <attribute name="rdf:ID"><data type="NCName"/></attribute>
        <element name="foaf:title"><text/></element>
        <element name="foaf:givenname"><text/></element>
        <element name="foaf:family_name"><text/></element>
        <element name="foaf:mbox">
          <attribute name="rdf:resource">
            <data type="anyURI"/>
          </attribute>
        </element>
        <element name="foaf:phone">
          <attribute name="rdf:resource">
            <data type="NMTOKEN"/>
          </attribute>
        </element>
        <element name="foaf:workplaceHomepage">
          <attribute name="rdf:resource">
            <data type="anyURI"/>
          </attribute>
        </element>
      </element>
    </element>
  </start>
</grammar>
      

Enabling the Source Editor

In the first step we don't want to invest much time, so we just enable the source editor. We have to add the corresponding menu item to our menu.xml file. But since we want to enable it only for person documents, we have to test if the currently displayed document has the person resource type. Here's the extended menu.xml file. Note the resourceTypes attribute of the <block> element:

<?xml version="1.0"?>
<menu xmlns:i18n="http://apache.org/cocoon/i18n/2.1"    
  xmlns:uc="http://apache.org/cocoon/lenya/usecase/1.0"
  xmlns="http://apache.org/cocoon/lenya/menubar/1.0">
  <menus>
    <menu i18n:attr="name" name="File">
      <block areas="site authoring">
        <item uc:usecase="sitemanagement.create" href="?doctype=person">
          <i18n:translate>
            <i18n:text>New ... Document</i18n:text>
            <i18n:param>resourceType-person</i18n:param>
          </i18n:translate>
        </item>
      </block>
    </menu>      
    <menu i18n:attr="name" name="Edit">
      <block areas="authoring" resourceTypes="person">
        <item uc:usecase="editors.oneform">
          <i18n:text>editors.sourceEditor</i18n:text>
        </item>
      </block>
    </menu>      
  </menus>
</menu>

Now you should be able to edit your person document with the source editor.

In the next section we explain how to make person documents editable with the BXE WYSIWYG editor.

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