J2EE and XML development - user interface (3)

zhaozj2021-02-16  43

J2EE Application User Interface Development (3) Author Kurt A. Gabrick David B. Weiss Source J2EE and XML Developments Chapter 5 Address << http://www.manning.com/gabrick >> This article is J2EE and XML development user interface Part III, if the example in the article is unfamiliar, please refer to the first, second part of this article.

J2EE and XML development user interface (1) << http://www.9cbs.net/develop/Article/19/19844.shtm >>.

4.3 Extension To binary format Before leaving the topic submitting an interface using XSLT, we need to look at the ability of XSLT formatted objects. The popular demand for advanced Web applications is to generate binary files. Using the XSLT Format Object (FO) implementation, you can convert data from dynamic XML data to binary format, such as files in PDF format. This section we describe this by implementing an example of a PDF file that generates a stock list. The Apache Software Foundation project FOP currently has partially implemented objects. You can download its documents and implementations from . To facilitate discussion, we assume that you need to generate a PDF file for the stock information table instead of an HTML file. Modify the example of our XSLT version to generate the PDF requires two steps

· We must modify the style table that generates HTML to generate a FOP formatted object tree replace the HTML page. We must use the XSLT Filter to call the FOP API and will format the object tree to PDF documents.

The so-called formatted object tree is a specific XSL style sheet that contains a set of print formatting instructions, and the FOP Driver component uses these instructions to create a PDF file from the XML document. The modification process of generating PDF is shown below

Create a format tree

The above figure shows the basic structure of the formatted tree style. Tree includes two main components: layout and page sequence. The layout describes a page template that can be used for one or more page sequences. Each page sequence defines the actual content displayed in the PDF, including all formatted information. In our example, we create a layout (master template) and a page sequence. Our page sequence will include a separate display information page.

Listing 4.11 includes a complete XSL style list of WatchList pages generated in US English version PDF format 4.11

In order to use the FO style, we must call the Apache FOP API. Because we don't want to implement our filter with a specific FO implementation, we use a class PDFWriter to pack it. This class requires a full path to format the tree style and an XML input data source and outputs the PDF to the specified output stream. To complete this work, PdfWriter uses Apache FOP and JAXP API for XSLT. This adapter's code is in list 4.12. List 4.12

Finally, the XSLT filter is modified so as to use PDFWriter when HTML is the output format. The modified class is listed in List 4.13 in List 4.13 in List 4.13.

The figure below shows the case of PDF output

5 XML Web Publishing Framework

Web Publishing Framework combines Java and XML technologies to become available architectures. Using a web publishing framework, you can create an XML-based representation layer without writing any custom code used to integrate XML. XML-based web publishing framework is still quite new, their reliability depends on the use of components, including the XML parser and the XSLT processor. Here are some popular web release frames: · Webmacro (http://www.webmacro.org) · ENHYDRA () · Cocoon () For the purpose of achieving the aforementioned XSLT, we now explore how to develop our stock example with the Cocoon Web release framework. 5.1 Cocoon Architecture Introduction Use Cocoon to develop user interface development including XSL styles and XSP page creation. Because XSP is currently limited to Cocoon, we will focus on Cocoon's XSLT capabilities. Below is the Cocoon processing flow chart

XML Server Pages (XSP) is a work guide for XML-based program-generating languages. XSP includes instructions that control how to be processed for a given XML dataset. The easiest way to use Cocoon is to add special processing instructions in your XML data document. These instructions allow COCOON to process and format your data and send it to the requested client. The supported output formats include WML, PDF, XML, and XHTML.

Cocoon producers are software components responsible for generating XML data. They are similar to the servlet function to receive and process HTTPSERVLETREQUEST. This is a scalable place of Cocoon, you can achieve your own producer to get the specified processing power. Cocoon uses FileProducer to read the requested file from the file system.

Once the CoCoon processor data is generated, they will be available for processing. The processor is a component responsible for operation (such as XML data produced by XSLT conversion producers). CoCoon includes the following processors: • XSLT processor • LDAP processor • XSP processor writes your own processor similar to writing JSP custom tags. The tag is created to process some logic and is used by the page.

Cocoon Format Help Format Help Help These components that may be applied to a response request. It is used to pack output content and add additional formatting information.

5.2 Submit stock information using COCOON Let us practice Cocoon, we will use standard Cocoon XSLT processors to convert our XML data as the XSLT converter. We have developed XSL style, so you only need to modify the XML document that returns the application logic layer. Add the Cocoon Processing Directive in our XSL style, as follows Then we add two instruction descriptions Apply to the data of the HTML and WML styles. For US regions, the instructions are as follows Media = WAP attribute tells Cocoon to select the corresponding style for WML users. Otherwise, the default style will be used. CoCoon is designed to access like servlet, but we can also use it by calling the API. In Listing 4.14, we modified the WatchListServlet, adding the appropriate instructions for processing the XML data document and calls the Cocoon Engine to convert and send a result to the customer. List 4.14

The figure below shows our new representation, which combines Cocoon and J2EE representing layer components to this full text.

More information 1. 2.

If you need to pay, please write the author and the source

转载请注明原文地址:https://www.9cbs.com/read-26872.html

New Post(0)