XML, XSLT, Java, and JSP: A Case Study in Developing a Web Application- P9
Thông tin tài liệu:
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ìm kiếm theo từ khóa liên quan:
lập trình java phương pháp lập trình lập trình web ngôn ngữ php lập trình cơ bản XMLTài liệu cùng danh mục:
-
Tìm hiểu về lỗi tràn bộ đệm (Buffer Overflow)
5 trang 364 0 0 -
Giáo trình Cấu trúc dữ liệu và thuật toán trên C++
74 trang 344 0 0 -
Bài giảng Phân tích thiết kế phần mềm: Chương 7 - Trường ĐH Ngoại ngữ - Tin học TP.HCM
16 trang 335 0 0 -
180 trang 274 0 0
-
Giáo trình Lập trình hướng đối tượng: Phần 2
154 trang 253 0 0 -
173 trang 248 2 0
-
Bài giảng Phân tích thiết kế và giải thuật - Chương 2: Kỹ thuật thiết kế giải thuật
80 trang 244 0 0 -
Kiến thức phần cứng máy tính - Sửa chữa nâng cấp và cài đặt máy tính xách tay Tập 2
483 trang 243 3 0 -
Kỹ thuật lập trình trên Visual Basic 2005
148 trang 242 0 0 -
Bài giảng Phân tích thiết kế phần mềm: Chương 6 - Trường ĐH Ngoại ngữ - Tin học TP.HCM
12 trang 240 0 0
Tài liệu mới:
-
8 trang 0 0 0
-
6 trang 0 0 0
-
Biện pháp tăng cường hoạt động vận động trước ảnh hưởng của lối sống hiện đại
4 trang 1 0 0 -
221 trang 0 0 0
-
6 trang 0 0 0
-
37 trang 1 0 0
-
Đề thi tuyển sinh vào lớp 10 môn Toán (Chuyên) năm 2024 có đáp án - Trường THCS Trường Yên, Hoa Lư
13 trang 1 0 0 -
Đề thi tuyển sinh vào lớp 10 môn Toán (Chuyên) năm 2024 có đáp án - Trường THCS Ninh Hải, Hoa Lư
10 trang 0 0 0 -
Đề thi tuyển sinh vào lớp 10 môn Toán (Chuyên) năm 2024 - Phòng GD&ĐT Nho Quan (Đề 2)
6 trang 1 0 0 -
29 trang 0 0 0