 2001 Prentice Hall, Inc. All rights reserved. Chapter 15 – Case Study: Message Forum with Active Server Pages Outline 15.1Introduction 15.2Setup and.

Slides:



Advertisements
Similar presentations
XML-XSL Introduction SHIJU RAJAN SHIJU RAJAN Outline Brief Overview Brief Overview What is XML? What is XML? Well Formed XML Well Formed XML Tag Name.
Advertisements

XML III. Learning Objectives Formatting XML Documents: Overview Using Cascading Style Sheets to format XML documents Using XSL to format XML documents.
CG0119 Web Database Systems Parsing XML: using SimpleXML & XSLT.
 2001 Prentice Hall, Inc. All rights reserved. 1.
XSL XSLT and XPath 11-Apr-17.
XML: Managing Data Exchange Stylesheets. Lesson Contents CSS The basic XSL file XSL transforms Templates Sort Numbering Parameters and Variables Datatypes.
1/18 ITApplications XML Module Session 5: Extensible Stylesheet Language (XSL)
Session 13 Active Server Pages (ASP) Matakuliah: M0114/Web Based Programming Tahun: 2005 Versi: 5.
Displaying and Using XML There are simple ways to use or display XML  CSS stylesheets  Data Source Objects  DHTML & Data Islands In later lessons we.
September 15, 2003Houssam Haitof1 XSL Transformation Houssam Haitof.
Chapter 2 Introduction to HTML5 Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
Chapter 12 Creating and Using XML Documents HTML5 AND CSS Seventh Edition.
DHTML. What is DHTML?  DHTML is the combination of several built-in browser features in fourth generation browsers that enable a web page to be more.
Cascading Style Sheets CS3505. What are CSS? Method for adding style attributes consistently to HML tags Cascading because styles are applied in order.
Chapter 4 HTML. Objectives Explain how HTML/XHTML are used and describe the difference between them Interpret HTML code Explain how HTML Forms are used.
_______________________________________________________________________________________________________________ E-Commerce: Fundamentals and Applications1.
 2001 Deitel & Associates, Inc. All rights reserved. 1 Chapter 12 – Microsoft FrontPage Express Outline 12.1Introduction 12.2Microsoft FrontPage Express.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 13 - Dynamic HTML: Object Model and Collections Outline 13.1 Introduction 13.2 Object Referencing.
CSS Cascading Style Sheets By Garrett Garman. CSS Why use Style Sheets? Separates Appearance and Structure Modularity Quick and Easy changes Flexibility.
HTML, XHTML, and CSS Chapter 12 Creating and Using XML Documents.
XP New Perspectives on XML Tutorial 6 1 TUTORIAL 6 XSLT Tutorial – Carey ISBN
WORKING WITH XSLT AND XPATH
Tutorial 6 By Sam INE 1020 Introduction to Internet Engineering 1 DHTML & CSS Tutorial 6.
1 JavaScript: Objects and Object Models October 25, 2005 Slides modified from Internet & World Wide Web: How to Program (3rd) edition. By Deitel,
Copyright © 2008 Pearson Prentice Hall. All rights reserved. 1 Exploring Microsoft Office Word 2007 Chapter 8 Word and the Internet Robert Grauer, Keith.
 HTML stands for Hyper Text Mark-up Language. The coding language used to create documents for the World Wide Web  HTML is composed of tags. HTML tags.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Tutorial 30 – Bookstore Application: Client Tier Introducing.
SEG3210 DHTML Tutorial. DHTML DHTML is a combination of technologies used to create dynamic and interactive Web sites. –HTML - For creating text and image.
Sheet 1XML Technology in E-Commerce 2001Lecture 7 XML Technology in E-Commerce Lecture 7 XSL Formatting Objects, Java Data Binding.
 2008 Pearson Education, Inc. All rights reserved Introduction to XHTML.
 2004 Prentice Hall, Inc. All rights reserved. 1 Chapter 34 - Case Study: Active Server Pages and XML Outline 34.1 Introduction 34.2 Setup and Message.
Client side web programming Introduction Jaana Holvikivi, DSc. School of ICT.
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 1 Database & Server-side Scripting Tutorial 10.
CITA 330 Section 6 XSLT. Transforming XML Documents to XHTML Documents XSLT is an XML dialect which is declared under namespace "
XSLT Kanda Runapongsa Dept. of Computer Engineering Khon Kaen University.
IST 221 Internet Concepts and Applications Introduction to XML II CSS and XSLT Style Sheets.
ALBERT WAVERING BOBBY SENG. Week 2: HTML + CSS  Quiz  Announcements/questions/etc  Some functional HTML elements.
XML Extensible Markup Language
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 13 - Dynamic HTML: Object Model and Collections Outline 13.1 Introduction 13.2 Object Referencing.
 2001 Deitel & Associates, Inc. All rights reserved. 1 Chapter 20 – Dynamic HTML: Object Model and Collections Outline 20.1Introduction 20.2Object Referencing.
1 Introduction  Extensible Markup Language (XML) –Uses tags to describe the structure of a document –Simplifies the process of sharing information –Extensible.
 2002 Prentice Hall, Inc. All rights reserved. 1 Chapter 12 – XSL: Extensible Stylesheet Language Transformations (XSLT) Outline 12.1Introduction 12.2Setup.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 13 - Dynamic HTML: Object Model and Collections Outline 13.1 Introduction 13.2 Object Referencing.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 24 – Case Study: ASP.NET and XML Outline 24.1 Introduction 24.2 Setup and Message Forum Documents.
1 Overview of XSL. 2 Outline We will use Roger Costello’s tutorial The purpose of this presentation is  To give a quick overview of XSL  To describe.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 6 - Cascading Style Sheets™ (CSS) Outline 6.1 Introduction 6.2 Inline Styles 6.3 Embedded Style.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 26 - Case Study: Active Server Pages and XML Outline 26.1 Introduction 26.2 Setup and Message.
Introduction to HTML. _______________________________________________________________________________________________________________ 2 Outline Key issues.
 2001 Prentice Hall, Inc. All rights reserved. Chapter 7 - Introduction to Common Gateway Interface (CGI) Outline 7.1Introduction 7.2A Simple HTTP Transaction.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
Tutorial 6 Working with Web Forms. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Explore how Web forms interact with.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved Bookstore Web Application: Client Tier Introducing Web Controls.
CSS Hadas Kahsay. Overview  What is CSS  Basic syntax of CSS Rules  How to link CSS style to html documents  Browsers and CSS  Advantages of CSS.
Cascading Style Sheets Primary readings Presentations Explain & review projects with class mates.
1 XMLXSL(T) and CSS NOEA/PQC (rev. fen) 2007 Stylesheets CSS:Cascading Style Sheets XSL(T):eXtended Stylesheet Language (Transformations)
XSLT: How Do We Use It? Nancy Hallberg Nikki Massaro Kauffman.
Cascading Style Sheets (CSS)
 2000 Deitel & Associates, Inc. All rights reserved. Chapter 15 – Dynamic HTML: Object Model and Collections Outline 15.1Introduction 15.2Object Referencing.
Chapter 29. Copyright 2003, Paradigm Publishing Inc. CHAPTER 29 BACKNEXTEND 29-2 LINKS TO OBJECTIVES Attach an XML Schema Attach an XML Schema Load XML.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 16 - Dynamic HTML: Data Binding with Tabular Data Control Outline 16.1 Introduction 16.2 Simple.
XML Schema – XSLT Week 8 Web site:
Rendering XML Documents ©NIITeXtensible Markup Language/Lesson 5/Slide 1 of 46 Objectives In this session, you will learn to: * Define rendering * Identify.
JavaScript and Ajax (JavaScript Dynamic HTML (DHTML)) Week 7 Web site:
CSS Introductions. Objectives To take control of the appearance of a Web site by creating style sheets. To use a style sheet to give all the pages of.
Session IV Chapter 14 – Chapter 14 – XSLThttp://
DHTML.
ASP.NET Forms.
Chapter 7 Representing Web Data: XML
Chapter 13 - Dynamic HTML: Object Model and Collections
Chapter 26 - Case Study: Active Server Pages and XML
Presentation transcript:

 2001 Prentice Hall, Inc. All rights reserved. Chapter 15 – Case Study: Message Forum with Active Server Pages Outline 15.1Introduction 15.2Setup and Message Forum Documents 15.3Forum Navigation 15.4Adding Forums 15.5Forum XML Documents 15.6Posting Messages 15.7Other HTML Documents

 2001 Prentice Hall, Inc. All rights reserved Introduction Creating a Web-based message forum with XML –Virtual bulletin boards –Use Microsoft’s Active Server Pages (ASP) technology

 2001 Prentice Hall, Inc. All rights reserved Setup and Message Forum Documents Setup instructions to execute case study Software requirements –Web server software Microsoft Personal Web Server (PWS) OR Microsoft Internet Information Services (IIS) OR Microsoft Internet Information Server (IIS) –Internet Explorer 5.5+ (for XML and XSLT processing) Place files in virtual Web directory –c:\inetpub\wwwroot

 2001 Prentice Hall, Inc. All rights reserved Setup and Message Forum Documents

 2001 Prentice Hall, Inc. All rights reserved Setup and Message Forum Documents default.asp –Displays list of available message forums stored in XML document forums.xml –Contains hyperlinks to each XML message forum document and to addForum.asp addForum.asp –Adds forums to document forums.xml –Creates new XML message forum using forum template template.xml formatting.xsl –Transforms each XML message forum document into HTML

 2001 Prentice Hall, Inc. All rights reserved Setup and Message Forum Documents site.css –CSS document formats HTML for display addPost.asp –posts new messages to forum invalid.html –Displays when errors occur during processing

 2001 Prentice Hall, Inc. All rights reserved Forum Navigation Fig. 15.2Key interactions between message forum documents.

 2001 Prentice Hall, Inc. All rights reserved. Outline Forum 1 Name forums.xml XML document that marks up the message forums. Root element forums can hold any number of message forums Stores name of XML document that contains forum’s markup name element marks up name of forum (used as a hyperlink descriptor in default.asp )

 2001 Prentice Hall, Inc. All rights reserved. Outline Deitel Message Forums Deitel Message Forums 19 Available Forums <% 22 Dim xmlFile, xmlNodes, xmlItem 23 Dim strPath, strTitle, strFileName strPath = Server.MapPath( "forums.xml" ) Set xmlFile = Server.CreateObject( "Microsoft.XMLDOM" ) 28 xmlFile.Async = False If Not xmlFile.Load( strPath ) Then 31 Call Response.Redirect( "invalid.html" ) 32 End If Set xmlNodes = xmlFile.DocumentElement.ChildNodes 35 default.asp Message forums main page. Sets scripting language to VBScript All variables must be declared explicitly Gets absolute path for file forums.xml and stores it in variable strPath CreateObject method instantiates a DOMDocument object ( Microsoft.XMLDOM ), assigns object to xmlFile Sets object referenced by xmlFile to behave synchronously Calls method Load to parse the XML document. Returns true if parsing succeeds, otherwise returns false DocumentElement property retrieves root element’s child nodes

 2001 Prentice Hall, Inc. All rights reserved. Outline 36 For Each xmlItem In xmlNodes 37 strFileName = xmlItem.getAttribute( "filename" ) 38 strTitle = xmlItem.text 39 %> "> Forum Management Add a Forum 52 Delete a Forum default.asp Message forums main page. For Each loop iterates through all nodes in child nodes collection. getAttribute method returns value of node’s filename attribute and assigns it to strFileName text property returns node’s text content (forum’s name) Creates an anchor with value of strFileName and uses strTitle as text description of anchor.

 2001 Prentice Hall, Inc. All rights reserved. Outline template.xml Template for message forum XML documents. The stylesheet processing instruction references formatting.xsl.

 2001 Prentice Hall, Inc. All rights reserved. Outline Empty Then If Request( "name" ) <> Empty And _ 13 Request( "filename" ) <> Empty And _ 14 Request( "user" ) <> Empty And _ 15 Request( "title" ) <> Empty And _ 16 Request( "text" ) <> Empty Then ' Lock application. No modifications but ours. 19 Call Application.Lock() ' Creating a new XML file. 22 strPath = Server.MapPath( Request( "filename" ) ) Set xmlFile = Server.CreateObject( "Microsoft.XMLDOM" ) 25 xmlFile.Async = False If xmlFile.Load( strPath ) Then 28 Call Application.Unlock() 29 Call Response.Redirect( "invalid.html" ) 30 End If ' Set up the file. 33 Call xmlFile.Load( Server.MapPath( "template.xml" ) ) 34 addForum.asp Page to add a forum. Test to see if the form was submitted by testing the form’s Submit field for a value. Check to see if a value was entered in each of the form fields. Method Load loads the template XML document.

 2001 Prentice Hall, Inc. All rights reserved. Outline 35 ' Get the root node. 36 Set xmlRoot = xmlFile.DocumentElement ' Set the filename. 39 Call xmlRoot.SetAttribute( "filename", _ 40 Request( "filename" ) ) ' Create Name node. 43 Set xmlNode = xmlFile.CreateElement( "name" ) 44 xmlNode.Text = Request( "name" ) 45 Call xmlRoot.AppendChild( xmlNode ) ' Create first message. 48 Set xmlNode = xmlFile.CreateElement( "message" ) 49 Call xmlNode.SetAttribute( "timestamp", Now & " EST" ) 50 Call xmlRoot.AppendChild( xmlNode ) Set xmlRoot = xmlNode ' Create user node. 55 Set xmlNode = xmlFile.CreateElement( "user" ) 56 xmlNode.Text = Request( "user" ) 57 Call xmlRoot.AppendChild( xmlNode ) ' Create title node. 60 Set xmlNode = xmlFile.CreateElement( "title" ) 61 xmlNode.Text = Request( "title" ) 62 Call xmlRoot.AppendChild( xmlNode ) ' Create text node. 65 Set xmlNode = xmlFile.CreateElement( "text" ) 66 xmlNode.Text = Request( "text" ) 67 Call xmlRoot.AppendChild( xmlNode ) Call xmlFile.Save( strPath ) ' Save the file. addForum.asp Page to add a forum. Method setAttribute creates an attribute node named filename that has the value contained in form field filename. Method AppendChild appends the newly created element name node to the root element. Save method saves the XML document to disk.

 2001 Prentice Hall, Inc. All rights reserved. Outline ' Load XML file. 72 strPath = Server.MapPath( "forums.xml" ) Set xmlFile = Server.CreateObject( "Microsoft.XMLDOM" ) 75 xmlFile.Async = False If Not xmlFile.Load( strPath ) Then 78 Call Application.Unlock() 79 Call Response.Redirect( "invalid.html" ) 80 End If ' Get the root node. 83 Set xmlRoot = xmlFile.DocumentElement ' Create Nodes. 86 Set xmlNode = xmlFile.CreateElement( "forum" ) 87 Call xmlNode.SetAttribute( "filename", _ 88 Request( "filename" ) ) 89 xmlNode.Text = Request( "name" ) 90 Call xmlRoot.AppendChild( xmlNode ) Call xmlFile.Save( strPath ) ' Save the file ' Finished processing. 95 Call Application.Unlock() 96 Call Response.Redirect( "default.asp" ) 97 Else 98 strError = "ERROR: Invalid input." 99 End If End If 102 %> 103 addForum.asp Page to add a forum. Open XML document forums.xml. Modify forums.xml. Save forums.xml with its new contents to disk.

 2001 Prentice Hall, Inc. All rights reserved. Outline Add a Forum Forum Name: 121 "> Forum File Name: 127 "> User: 133 "> Message Title: addForum.asp Page to add a forum. XHTML form allows user to input name, filename, user name, message title and message text to create a new forum.

 2001 Prentice Hall, Inc. All rights reserved. Outline 139 "> Message Text: Return to Main Page addForum.asp Page to add a forum. Submit button submits form and values from form fields. Button with input type reset deletes all values in form fields

 2001 Prentice Hall, Inc. All rights reserved. Outline addForum.asp Page to add a forum.

 2001 Prentice Hall, Inc. All rights reserved. Outline Forum 1 Name Person1 13 Title One 14 Text of message of Title One Person2 19 Title Two 20 Text of message of Title Two Person1 25 Title Three 26 Text of message of Title Three forum1.xml Sample forum. Name of forum. Message elements and child elements contain the information for a post.

 2001 Prentice Hall, Inc. All rights reserved. Outline formatting.xsl XSLT to transform XML forum document into HTML. Element xsl:stylesheet is the XSLT document’s root element Attribute version specifies the XSLT version to which this style sheet conforms. The attribute xmlns creates a namespace prefix xsl. This template that match es the XML document root ( / ). Get value of name element. Apply message template.

 2001 Prentice Hall, Inc. All rights reserved. Outline addPost.asp?file= Post a Message 41 Return to Main Page by at formatting.xsl XSLT to transform XML forum document into HTML. Get the value of attribute filename. Begin template message.Get value of user element.Get value of attribute timestamp.Get value of title element

 2001 Prentice Hall, Inc. All rights reserved. Outline formatting.xsl XSLT to transform XML forum document into HTML. Apply text property from template

 2001 Prentice Hall, Inc. All rights reserved. Outline Forum 1 Name Forum 1 Name Title One by 22 Person1 23 at 24 06/28/00 14: Text of message of Title One Title Two 35 Output of the transformation of the forum XML document. Forum title.Message title.Message author.Time and date posted. Message text.

 2001 Prentice Hall, Inc. All rights reserved. Outline by 39 Person2 40 at 41 06/29/00 14: Text of message of Title Two Title Three by 56 Person1 57 at 58 06/29/00 14: Text of message of Title Three Post a Message Output of the transformation of the forum XML document. Message author. Time and date posted. Message title. Message author.Time and date posted.Message text.Link to add a new post.

 2001 Prentice Hall, Inc. All rights reserved. Outline Return to Main Page Output of the transformation of the forum XML document.

 2001 Prentice Hall, Inc. All rights reserved. Outline Empty Then If Request( "file" ) <> Empty And _ 13 Request( "user" ) <> Empty And _ 14 Request( "title" ) <> Empty And _ 15 Request( "text" ) <> Empty Then ' Lock application. No modifications but ours. 18 Call Application.Lock() strPath = Server.MapPath( Request( "file" ) ) Set xmlFile = Server.CreateObject( "Microsoft.XMLDOM" ) 23 xmlFile.Async = False If Not xmlFile.Load( strPath ) Then 26 Call Application.Unlock() 27 Call Response.Redirect( "invalid.html" ) 28 End If ' Get the root node. 31 Set xmlRoot = xmlFile.DocumentElement ' Create first message. 34 Set xmlNode = xmlFile.CreateElement( "message" ) 35 Call xmlNode.SetAttribute( "timestamp", Now & " EST" ) addPost.asp Adding a message to a forum. Test to see if the form was submitted by testing the form’s Submit field for a value. Check to see if a value was entered in each of the form fields. Method Load loads the forum XML document. Create a message node.Create a timeStamp attribute for the message node.

 2001 Prentice Hall, Inc. All rights reserved. Outline 36 Call xmlRoot.AppendChild( xmlNode ) Set xmlRoot = xmlNode ' Create user node. 41 Set xmlNode = xmlFile.CreateElement( "user" ) 42 xmlNode.Text = Request( "user" ) 43 Call xmlRoot.AppendChild( xmlNode ) ' Create title node. 46 Set xmlNode = xmlFile.CreateElement( "title" ) 47 xmlNode.Text = Request( "title" ) 48 Call xmlRoot.AppendChild( xmlNode ) ' Create text node. 51 Set xmlNode = xmlFile.CreateElement( "text" ) 52 xmlNode.Text = Request( "text" ) 53 Call xmlRoot.AppendChild( xmlNode ) Call xmlFile.Save( strPath ) ' Save the file ' Finished processing. 58 Call Application.Unlock() 59 Call Response.Redirect( Request( "file" ) ) 60 Else 61 strError = "ERROR: Invalid input." 62 End If End If 65 %> addPost.asp Adding a message to a forum. Create the children of the message node: user, title and text.

 2001 Prentice Hall, Inc. All rights reserved. Outline Post a Message User: 83 "> Message Title: 88 "> Message Text: "> addPost.asp Adding a message to a forum. Form allows the user to create a post by entering the values into the form fields.

 2001 Prentice Hall, Inc. All rights reserved. Outline ">Return to Forum addPost.asp Adding a message to a forum. Program Output

 2001 Prentice Hall, Inc. All rights reserved. Outline Deitel Book Organization Invalid Request Return to Main Page invalid.html Document showing that an error has occurred. Link that references CSS style sheet site.css.

 2001 Prentice Hall, Inc. All rights reserved. Outline 1 /* Fig : site.css */ 2 3 BODY 4 { 5 background: white; 6 color: black; 7 font-family: Arial, sans-serif; 8 font-size: 10pt; 9 } a 12 { 13 background: transparent; 14 color: blue; 15 text-decoration: none; 16 } a:hover 19 { 20 text-decoration: underline; 21 } table 24 { 25 border-width: 1px; 26 border-style: solid; 27 } forumTitle 30 { 31 background: lime; 32 color: black; 33 font-size: 12pt; 34 font-weight: bold; 35 text-align: center; site.css CSS document for HTML pages. Define styles for the body element.Define styles for the anchor element.Define styles for the table element.

 2001 Prentice Hall, Inc. All rights reserved. Outline 36 } msgTitle 39 { 40 background: silver; 41 color: black; 42 font-size: 10pt; 43 font-weight: bold; 44 } msgInfo 47 { 48 background: silver; 49 color: black; 50 font-size: 10pt; 51 } msgPost 54 { 55 background: silver; 56 color: black; 57 font-size: 8pt; 58 } msgText 61 { 62 font-size: 10pt; 63 padding-left: 10px; 64 } date 67 { 68 font-size: 8pt; 69 } site.css CSS document for HTML pages.