Searching for affordable and proven webhost to host and run your servlet applications? Go to Linux Web Hosting services and you will find it.
CHAPTER 4 CLIENT-SIDE XML 119 Generating XML on the Server The first step is much like building a dynamic web page, except that instead of generating XHTML, the application generates XML. The structure of the XML depends on the data source and the application. Transforming the XML Content into XHTML In the second stage, the application determines where the transformation should take place and transforms the data. The result of the transformation is an XHTML document that contains CSS references. If the client has the capability to transform the data, it should apply the stylesheet at that point to reduce the load on the server. However, this determination must be made on the server, so that you can apply a server-side transformation if necessary. If you re using XSLT to access a small amount of content from a larger XML document, the overhead of sending the XML to the browser may be more than the time saved in client-side processing. It may make more sense to transform the content on the server and deliver XHTML to the browser. Another alternative is to combine both server-side and client-side transformations. The server-side transform selects the content and delivers XML to the client. The client then performs another transformation to generate the final XHTML. Styling the XHTML with CSS Once the browser receives the XHTML content, it is styled with CSS either through a linked external stylesheet or through embedded or inline CSS declarations. The result is a styled XHTML page. Advantages and Disadvantages Transforming XML into XHTML is a useful approach because it offers the following advantages compared with traditional XHTML-based dynamic web pages: The application separates the data, layout, and styling of pages quite rigidly. Separating styling provides more manageability for web applications. This type of architecture can be easily adapted to a server farm environment. The application can target different platforms with the same server-side code. For example, the same content can be presented on web and mobile-phone browsers by applying a different XSLT stylesheet for each device. The same application can be used for multiple purposes. For example, stylesheets could transform application-specific XML into a format suitable for sharing with business partners. They could then browse the transformed XML with a corporate system, allowing both parties to interact without making major changes to either system. Bear in mind that if you apply XSLT transformations on the server side, the server must carry out additional processing. Through this process, you may lose gains arising from reduced server traffic.
Check Tomcat Web Hosting services for best quality webspace to host your web application.
118 CHAPTER 4 CLIENT-SIDE XML Using XML Within a Dynamic Web Page In this approach, the application processes XML using a server-side scripting language, such as C#, VB .NET, PHP, or JavaServer Pages (JSP), and presents the end result to the browser as XHTML. The browser can then style the content using server-side languages that provide DOM or SAX support, allowing the application to process XML content easily. Transforming XML into XHTML The second approach is to generate XML and use XSLT to transform it into XHTML for presentation on the browser. You can apply the XSLT stylesheet transformation on either the server or client, depending on the browser capabilities. If the browser has XSLT support, the transformation occurs there; otherwise, it takes place on the server. Once generated, the application can style the XHTML in the browser using CSS. Figure 4-11 shows the workflow involved in this approach. Figure 4-11. The process of transforming XML into XHTML This architecture involves the following steps: 1. Generate XML on the server. 2. Transform the XML content into XHTML on either the server or client. 3. Style the XHTML with CSS. I ll explain each step in a little more detail.
Check Tomcat Web Hosting services for best quality webspace to host your web application.
CHAPTER 4 CLIENT-SIDE XML 117 Using Client-Side XML At the beginning of this chapter, you saw that the main benefits of working with XML on the client were a reduction of traffic between server and client, and a reduction in server-side load. Let s examine these concepts more closely with an example. Suppose you need to display a list of properties that are for sale on a web site. Using XHTML and server-side processing, you could Load a list of the property addresses and allow users to drill down to view the details of each property on a separate page List all details of every property in a list on a single page The second approach isn t practical. If you need to display a large number of properties, the page will be very long and will take a long time to download. You will also have a hard time locating information. In the first approach, viewing the details of a new property requests information from the server, which reloads the interface to display those details. Even if you need only a small amount of information, you ll still need to refresh the page and load additional content from the server each time. Separating the content from the interface saves server traffic and download times each time you want to view another property. One solution is to use XML on the client side. The server downloads the interface once, when you first load the page. Each time you request further property details, you can download the new content to the client, transform and style the XML into the desired format, and insert the styled content into the cached interface. The only problem with this approach is that the application can only run in a client that has the appropriate level of XML support. If the content is served within a web browser, you need to be careful, because the level of support differs greatly between the major players. For example, Opera versions 8 and below don t support XSLT. Using Server-Side XML One solution might be to process the XML on the server instead. Using server-side processing can avoid any of the specific browser issues. However, as discussed, this means users place more load on the server with more frequent trips to request information. Unless you re dealing with a particularly data-intensive application, this isn t likely to overshadow the advantages of the server-side approach. I ll discuss this in more detail in Chapters 11 to 13, where you ll see some approaches to using server-side XML. There are three broad approaches to using XML in web browser applications: Using XML on the server side only and sending XHTML to the web browser Transforming the XML into XHTML for delivery to the browser Serving XML to the web browser and manipulating it with client-side scripting I ll look at each of these approaches in the following sections. I ll examine Flash as a special case in Chapter 10.
If you are in need for cheap and reliable webhost to host your website, we recommend http web server services.
116 CHAPTER 4 CLIENT-SIDE XML The aim of the project is to provide online content for students and teachers through learning objects. A high proportion of the learning objects available use Flash and XML for portability and platform independence. You can find examples of learning objects at http:// www.thelearningfederation.edu.au/tlf2/showMe.asp?nodeID=242#groups. Figure 4-10 shows one learning object. Figure 4-10. A Flash movie displaying XML content Now that I ve covered the range of client-side options available for working with XML data, let s examine when client-side processing is appropriate. Choosing Between Client and Server It s important to decide whether an XML application should use client-side XML, server-side XML, or some combination of the two types of processing. So far, you ve seen several clients that can work with XML content. In Chapters 5 to 10, you ll look at client-side communication in more detail. Chapters 11 to 13 will examine server-side applications. In this section, I ll cover different approaches for client-side and server-side interactions in XML applications.
If you are looking for affordable and reliable webhost to host and run your business application visit our ftp web hosting services.
CHAPTER 4 CLIENT-SIDE XML 115 Figure 4-9. Raw XML content displayed in Opera 8.5 You can see the content within the XML document by choosing View . Source. Determining XML Content Opera uses the content type followed by the file extension to determine whether a file contains XML content. In addition, Opera looks at the first line of the file for an XML declaration. Opera also checks whether an XML document is well formed. As with the other browsers, Opera generates a parser error if it loads a document that is not well formed. However, unlike the other browsers, Opera displays the part of the XML file that it successfully parsed prior to reaching the error. Using Proprietary Functionality in Opera Opera doesn t offer much in terms of proprietary XML tools. However, it offers native support for some XML vocabularies: native SVG 1.1 Tiny and native WML. Native SVG 1.1 Tiny Support Opera has native support for SVG 1.1 Tiny, a subset of the SVG recommendation suitable for cell phones. This means that Opera natively supports SVG opacity, font handling, and animation. Native WML Support WML is a vocabulary of XML used to mark up documents for display in mobile phone-based browsers. Opera supports most of WML 1.3 and WML 2.0, and Opera is the only major browser to offer support of WML natively. Adobe (Formerly Macromedia) Flash Flash provides another option for the display and manipulation of XML content. Since version 5, Flash has been able to parse XML documents into a tree. Flash uses an internal XML class that is similar to, but not fully compliant with, the W3C DOM. One advantage of Flash movies is that they can display in a web browser or within standalone applications. You can find out more about Flash and XML in Chapter 10. The Le@rning Federation project provides a good example of using XML with Flash. This project is an initiative of the governments of Australia, the Australian states, and New Zealand. You can find out more about the project at http://www.thelearningfederation.edu.au/.
Please visit our professional web hosting services to find out about cheap and reliable webhost service that will surely answer all your demands.
114 CHAPTER 4 CLIENT-SIDE XML XUL XUL (pronounced zool and rhymes with cool) is a proprietary language created by Mozilla that describes Mozilla user interfaces. You can use XUL to create interfaces containing elements such as form controls, toolbars, and menus. The advantage is that it provides a simple way to define user interface widgets. You might use XUL to add functionality to Mozilla or to create complete applications such as Firefox and Thunderbird. XUL is beyond the scope of this book, but you can find a great introduction to it at http://developer.mozilla.org/en/docs/XUL_Tutorial. XBL XBL works with XUL to describe the behavior of XUL widgets. Again, Mozilla developed XBL and submitted it as a note to the W3C. It provides similar functionality to IE XML data binding, combined with IE DHTML behaviors. You can find out more about XBL at http:// developer.mozilla.org/en/docs/XUL_Tutorial:Introduction_to_XBL. Native SVG Support Chapter 3 introduced you to SVG. The latest version of Firefox, 1.5, includes native SVG for most of the SVG 1.1 recommendation. It doesn t include support for filters, SVG-defined fonts, and declarative animations. Netscape 8 doesn t offer SVG support. Opera Opera has supported XML since version 4, but it doesn t yet have the same level of support offered by the other major browsers. At the time of writing, the next release, 9.0, plans to increase XML support. Examining the Expat Parser Like Mozilla, Opera also makes use of the Expat open source parser. W3C DOM Support Opera 8 has full support of XML DOM 2. XSLT Opera 8.5 has no support for XSLT stylesheets, though it s planned for the forthcoming release of Opera 9. You must apply XSLT stylesheet transformations on the server side if you re targeting Opera. Viewing Raw XML in Opera Opera ignores the XML tags within a document and displays only the content from the elements, in accordance with the recommendation. Figure 4-9 shows how the XML document dvd.xml, displays in Opera. Opera treats all elements as inline and renders all text in the same font.
You want to have a cheap webhost for your apache application, then check apache web hosting services.