1 / 55

Chapter 34 - Case Study: Active Server Pages and XML

Chapter 34 - Case Study: Active Server Pages and XML. Outline 34.1 Introduction 34.2 Setup and Message Forum Documents 34.3 Forum Navigation 34.4 Adding Forums 34.5 Forum XML Documents 34.6 Posting Messages 34.7 Other Documents 34.8 Web Resources. Objectives.

jkelso
Download Presentation

Chapter 34 - Case Study: Active Server Pages and XML

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 34 - Case Study: Active Server Pages and XML Outline 34.1 Introduction 34.2 Setup and Message Forum Documents 34.3 Forum Navigation 34.4 Adding Forums 34.5 Forum XML Documents 34.6 Posting Messages 34.7 Other Documents 34.8 Web Resources

  2. Objectives • In this tutorial, you will learn: • To create a Web-based message forum using Active Server Pages. • To use XML with Active Server Pages. • To be able to add new forums. • To be able to post messages to the message forum. • To use Microsoft’s DOM to manipulate an XML document. • To use XSLT to transform XML documents.

  3. 34.1 Introduction • Message forums • Popular internet feature • Discuss topics • Exchange information • Several major sites provide this service • messages.yahoo.com/index.html • web.eesite.com/forums • groups.google.com

  4. 34.2 Setup and Message Forum Documents • Prerequisites • Microsoft Internet Information Services 6 (IIS) • Internet Explorer 6 (for XML and XSLT processing) • MSXML 3.0 or higher • Write permissions on forum folder

  5. 34.2 Setup and Message Forum Documents

  6. 34.3 Forum Navigation Fig. 34.2 Key interactions between message forum documents. default.asp forums.xml addForum.asp forumASP.xml formatting.xsl addPost.asp

  7. 34.2 Setup and Message Forum Documents • Forum listing • XML • filename attribute

  8. XML document that contains the information for forum ASP. Name of forum. forums.xml(1 of 1)

  9. 34.2 Setup and Message Forum Documents • Presenting forum listing • Convert to XHTML • CSS for formatting • ASP facilitates the conversion • DOMDocument • Async property • DocumentElement • ChildNodes • For Each…Next control structure

  10. Link to CSS style sheet style.css. default.asp(1 of 3)

  11. Setting Async to False causes the object referenced by xmlFile to behave synchronously. Property DocumentElement gets the root element’s child nodes. Property ChildNodes returns a collection of the element node’s child nodes. Method getAttribute gets a forum’s filename. The anchor element creates a link to the available forums. Instantiate an XML DOM object. Method Load parses the XML document forums.xml. If the parsing fails, the browser is redirected to invalid.html. default.asp(2 of 3)

  12. This anchor element links to the ASP document addForum.asp that allows the user to create a new forum. default.asp(3 of 3)

  13. 34.3 Forum Navigation Fig. 34.4 Message forums main page.

  14. 34.3 Adding Forums • Template forum • Bare minimum elements of forum • stylesheet tag for formatting • forum tag

  15. The stylesheet processing instruction references formatting.xsl. template.xml

  16. 34.3 Adding Forums • Generating forum from template • Form to get information on new forum • Name and file name • User name • Message title and text • Script to act on form input • Confirm valid input • SetAttribute • filename • timestamp • CreateElement • AppendChild • Save

  17. Check to see if a value was entered in each of the form fields. Test to see if the form was submitted by testing the form’s submitfield for a value. addForum.asp(1 of 7)

  18. Method Loadloads the template XML document. Method setAttribute creates an attribute node named filename that has the value contained in form field filename. Method AppendChildappends the newly created element name node to the root element. addForum.asp(2 of 7)

  19. Open XML document forums.xml. Calling method Savesaves theXML document to disk. addForum.asp(3 of 7)

  20. Modify forums.xml. Save forums.xml with its new contents to disk. addForum.asp(4 of 7)

  21. This XHTML form allows a user to input the name, filename, a user name, a message title and the message text to create a new forum. addForum.asp(5 of 7)

  22. addForum.asp(6 of 7)

  23. The Submit button submits the form and the values input in the form fields. The Clear button will delete all values in the form fields. addForum.asp(7 of 7)

  24. 34.3 Adding Forums Fig. 34.6 Page to add a forum.

  25. 34.5 Forum XML Documents • Sample forum • XML modified with several forums added • XSLT used to transform XML • Final XHTML page served to Internet Explorer

  26. The name of the forum. Each message element and its children contain the information for a post. forumASP.xml(1 of 2)

  27. forumASP.xml(2 of 2)

  28. Attribute version specifies the XSLT version to which this style sheet conforms. Element xsl:stylesheetis the XSLT document’s root element. The attribute xmlns creates a namespace prefix xsl. The xsl:output element specifies how the result tree is output. Attribute omit-xml-declaration is assigned no, which results in an XML declaration in the result tree. Attribute method is assigned html, which specifies that an XHTML document is being output. Select the templatethatmatches the XML document root (/). The asterisk selects element nodes. formatting.xsl(1 of 4)

  29. Link to the CSS style sheet style.css. Get value of name element. Apply message template. formatting.xsl(2 of 4)

  30. Get the value of attribute filename. Begin template message. Get value of user element. formatting.xsl(3 of 4)

  31. Get value of attribute timestamp. Get value of textelement. formatting.xsl(4 of 4)

  32. Forum title. Message title. forumASP_transformed.html(1 of 3)

  33. Time and date posted. Message text. Message author. forumASP_transformed.html(2 of 3)

  34. Link to add a new post. forumASP_transformed.html(3 of 3)

  35. 34.5 Forum XML Documents Fig. 34.9 Output of the transformation of the forum XML document.

  36. 34.6 Posting Messages • Posting a message • Procedure similar to creating new forum

  37. Check to see if a value was entered in each of the form fields. Test to see if the form was submitted by testing the form’s submit field for a value. Method Load loads the forum XML document. addPost.asp(1 of 5)

  38. Create a message node. Create a timeStampattribute for the messagenode. Create the children of the message node: user, titleand text. addPost.asp(2 of 5)

  39. addPost.asp(3 of 5)

  40. This form allows the user to create a post by entering the values into the form fields. addPost.asp(4 of 5)

  41. addPost.asp(5 of 5)

  42. 34.6 Posting Messages Fig. 34.10 Adding a message to a forum.

  43. 34.6 Posting Messages Fig. 34.11 New forum on the message board.

  44. 34.6 Posting Messages Fig. 34.12 Initial content of the newly added forum.

  45. 34.6 Posting Messages Fig. 34.13 Contents of the Internet and World Wide Web: Third Edition forum.

  46. 34.7 Other Documents • Other documents required by forum • Error page • CSS for formatting • XHTML • Forums

  47. Link that references CSS style sheet site.css. invalid.html(1 of 1)

  48. Define styles for the bodyelement. Define styles for the anchor element. Define styles for the table element. site.css (1 of 3)

  49. site.css (2 of 3)

  50. site.css (3 of 3)

More Related