中国IT动力,最新最全的IT技术教程
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档 | 网通镜像
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 硬件维护 | 未整理篇 | 站长教程
ASP JS PHP工程 ASP.NET 网站建设 UML J2EESUN .NET VC VB VFP 网络维护 数据库 DB2 SQL2000 Oracle Mysql
服务器 Win2000 Office C DreamWeaver FireWorks Flash PhotoShop 上网宝典 CorelDraw 协议大全 网络安全 微软认证
硬件维护  CPU  主板  硬盘  内存  显卡  显示器  键盘鼠标  声卡音箱  打印机  机箱电源  BIOS  网卡  C#  Java  Delphi  vs.net2005
  当前位置:> 程序开发 > 编程语言 > Java > Java与XML
Publishing XML Documents in PDF and HTML with Cocoon
作者:未知 时间:2005-08-10 19:01 出处:Java频道 责编:chinaitpower
              摘要:Publishing XML Documents in PDF and HTML with Cocoon
his article shows you how to publish XML documents in PDF using Apache Cocoon. Cocoon can create result documents in a variety of formats, including HTML and PDF. Cocoon's popularity reflects that of the Adobe's PDF format, which most vendors prefer for e-mailing richly formatted printable documents and reports. Cocoon converts not only text content, but also graphs and images. This article focuses on using Cocoon to dynamically generate HTML and PDF.

Although there are alternatives for generating PDF, Cocoon is preferred because it provides various value-added features. For example, the Cocoon site says: "Cocoon interacts with many data sources, including file systems, RDBMS, LDAP, native XML databases, SAP systems, and network-based data sources. It adapts content delivery to the capabilities of different devices like HTML, WML, PDF, SVG, and RTF, to name just a few. You can run Cocoon as a Servlet as well as through a powerful, command line interface. The deliberate design of its abstract environment gives you the freedom to extend its functionality to meet your special needs in a highly modular fashion." You can find a complete feature list at http://cocoon.apache.org/2.1/features.html.

What You Need
To gain the greatest benefit from this article, you should be somewhat familiar with XML/XSL and J2EE. You can use any Java Web application server; I used the JBoss 3.2.1 server to test the article code.

Follow these steps to get started:

  1. Download Cocoon 2.15
  2. Build and install Cocoon
  3. Create or download the source code files to build the examples in this article (the XML, XMAP, XSL, and JSP files)
  4. Test the application
The rest of this article describes how to perform each of the steps in more detail.

Download the Cocoon Source
To get Cocoon and configure it for your server, first download the latest version from http://Cocoon.apache.org/2.1/index.html.

Building Cocoon
The following procedure lists the steps to build and deploy Cocoon.

  1. Execute build (default target)—just type build on the command prompt in the directory where you installed Cocoon (by default that's C:\Java\Cocoon-2.1.5.
  2.  
    Figure 1. The Cocoon Welcome Page: After building and installing Cocoon as described in this article, you should see this page by browsing to the default Welcome page (http://localhost:8080/cocoon/).
  3. Next, build the war file using the command build war.
Author's note: These are separate commands. Perform both build, and build war.

  1. Deploy the Cocoon Web application war file by copying the Cocoon.war file generated by the build process in step 2 from \Cocoon-2.1.5\build\Cocoon-2.1.5\Cocoon.war to the default\deploy directory. When you complete these steps Cocoon should be up and running on JBoss.
  2. Test your Cocoon installation by starting the JBoss server and go to http://localhost:8080/cocoon/. If the installation succeeded, you'll see the screen shown in Figure 1.
Author's Note: The information in this article assumes that you're running your local HTTP server on port 8080.

关闭本页
 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 chinaitpower.com All rights reserved. www.chinaitpower.com 版权所有