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

Integrating external data How-To

Table of Contents
  • First Solution
  • Second Solution

This article is about how to pull XML data from another web server and integrate it into a Lenya website. Your first decision is where Lenya enters your code. There are two good possibilities for your goals:

  1. Interrupt before <map:match pattern="**.html">
  2. Interrupt at getting the data.

First Solution

1. Interrupt before <map:match pattern="**.html"> Add a match and write everything needed to create your page. {1} = url before "/people/" {2} = url between "people/" and ".html"

            <map:match pattern="**/people/*.html">
                 <map:aggregate element="cmsbody">
                     <map:part src="cocoon://navigation/{page-envelope:publication-id}/{page-envelope:area}/breadcrumb/index.xml"/>
                     <map:part src="cocoon://navigation/{page-envelope:publication-id}/{page-envelope:area}/tabs/index.xml"/>
                     <map:part src="cocoon://navigation/{page-envelope:publication-id}/{page-envelope:area}/menu/index.xml"/>
                     <map:part src="cocoon://navigation/{page-envelope:publication-id}/{page-envelope:area}/search/index.xml"/>
                     <map:part src="cocoon:/people-{2}"/>
                 </map:aggregate>
                 <map:transform src="xslt/page2xhtml-people.xsl"/>
                 <map:serialize type="xml"/>
             </map:match>

(You should copy all the code in <map:match pattern="lenyabody-*/*/*/*/**">.

              <map:match pattern="people-**">
                 <map:generate src="http://www.xmlhack.com/cdf.cdf?{1}"/>
                 <map:transform src="xslt/xmlhack.xsl"/>
                 <map:serialize type="html"/>
             </map:match>

Notice I added the filename requested (without an extension) to the querystring of the remote request.

Second Solution

2. Interrupt at getting the data. 2.a Set a new doctype in "parameter-doctype.xmap". This code must be before <map:match pattern="*/**.html">:

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

2.b Get the content from the remote source in "doctypes.xmap". This code must be before <map:match pattern="*/*/*/**.xml">: {1} = "view" {2} = area {3} = document=path with final ".xml" removed

             <map:match pattern="*/*/people/**.xml">
                 <map:generate src="http://www.xmlhack.com/cdf.cdf?{3}"/>
                 <map:transform src="xslt/people2xhtml.xsl">
                     <map:parameter name="rendertype" value="{1}"/>
                     <map:parameter name="nodeid" value="{page-envelope:document-node-id}"/>
                     <map:parameter name="language" value="{page-envelope:document-language}"/>
                 </map:transform>
                 <map:serialize type="xml"/>
             </map:match>

Notice I added the filename requested (without an extension) to the querystring of the remote request.

2.c Use these filenames for your transformation: xslt/people2xhtml.xsl (Use whatever is specified in 2.b, but this is the standard naming convention.) xslt/page2xhtml-people.xsl I recommend the second option. It is much less code (less chance of bugs), and takes advantage of Lenya's standards.

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