Danh mục

XML, XSLT, Java, and JSP: A Case Study in Developing a Web Application- P9

Số trang: 50      Loại file: pdf      Dung lượng: 1.62 MB      Lượt xem: 13      Lượt tải: 0    
Thu Hiền

Xem trước 5 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

XML, XSLT, Java, and JSP: A Case Study in Developing a Web Application- P9: Là một nhà phát triển Web, bạn biết những thách thức trong việc xây dựng các ứng dụng mạnh mẽ trên nhiều nền tảng. Tạo các ứng dụng di động trở nên thật sự có thể bằng cách sử dụng Java cho code và XML để tổ chức và quản lý dữ liệu. "XML, XSLT, Java, và JSP: Một trường hợp học" sẽ giúp bạn tối đa hóa khả năng của XML, XSLT, Java, và JSP trong các ứng dụng web của bạn....
Nội dung trích xuất từ tài liệu:
XML, XSLT, Java, and JSP: A Case Study in Developing a Web Application- P9382 Chapter 10 JSP Taglib: The bonForum Custom Tags the transform tag is called, invoking the methods of its handler class.The following code in that handler, from TransformTag.java, takes care of getting the style-sheet para- meter: String param1 = (String)pageContext.getSession( ).getAttribute( “param1” ); if( param1 == null) { param1 = “”; } The TransformTag class invokes an XSLT processing method in one of several ways, depending on the tag attribute values. Every such invocation, whether for Xalan-Java 1 or Xalan-Java 2, passes the style-sheet parameter as an argument, like this: transformer.transform(inXML, inXSL, outDoc, param1) 10.9.5 How the Style Sheet works The first template in the style sheet matches the root node. It begins an HTML select element and then applies templates to all the bonForum.things nodes. A chat element is found whose itemKey value matches the param1 value passed by the JSP tag action.That is the current chat for the session.The children of that chat element are iterated looking for any guestKey elements.Whenever one is found, its value (a nodeKey string) is saved in the guestKey-value variable, and the processing jumps to a different place altogether in the bonForum XML data: Guest elements (children of the bonForum.actors node) are iterated.When a guest element nodeKey value matches the saved guestKey value, that element is a guest in the chat. Its nickname, age, and rating element contents can now be concatenated as an HTML option for the select that is being built by this style sheet.The iteration of the guestKeys in the chat continues until all the HTML option strings have been output.The closing tag for the HTML select is output as well. Why the Style Sheet Is Used As we discussed in the section “The changeChatActorRating() Method” in Chapter 8, a chat host has commands available to raise or lower the rating of any guest in the “current” chat. (That functionality will later be extended to allow any chat actor to rate any other one in its chat.) Now you know how that host gets a list of the guests in its chat so that it can pick one to promote or demote. 10.9.6 JSP Tags and XSLT in the Future One of the main goals of our Web application design is that it should be extensible and customizable using technologies designed for such purposes.The two most pow- erful ways to turn the bonForum prototype into a chat that is visually appealing and full of features are JSP custom tags and XSLT processing. 10.9 Displaying the Guests in a Chat 38310.9.7 Sending Feedback to the AuthorWe hope that you enjoy altering and improving the JSP documents and the XSL stylesheets as much as we enjoyed creating the ones shown here.To send your own solu-tions, improvements, donations, and flames, or to discuss the contents of this book, feelfree to email the author of this book at email@bonforum.org, or use the forums andmailing lists provided by SourceForge to reach the bonForum project Web site:http://www.bonforum.org. 11 XML Data Storage Class: ForestHashtableI N THIS CHAPTER, YOU CAN LEARN HOW we implemented data storage for the XMLdata in the bonForum chat application. A descendant of the Hashtable class adds a fewtricks to optimize XML element retrieval, as it simulates our design for a relationaldatabase schema.11.1 Overview of bonForum Data StorageOne of the more controversial aspects of the bonForum project has been its data stor-age implementation.Throughout this chapter, we will include some of the objectionsthat have been raised. Perhaps the most common question is why did we not use arelational database. Certainly, that would not have been as difficult as creating theForestHashtable class in Java, right? Questions are also raised about the way wedesigned our objects.These questions deserve an answer, so here are three: n We are not against using a database—in fact, we will. However, we wanted to design ours (and experiment with its design) without using a database tool. As you read this chapter, be aware that we are not trying to replace the use of a database engine—or to reinvent, one either. n Our objective was never to design the best way of storing, manipulating, and retrieving XML data using Java obje ...

Tài liệu được xem nhiều:

Tài liệu cùng danh mục:

Tài liệu mới: