Solved Practical Questions (Model Question, 2068(i), 2068(II), 2069, 2071 Bsc. CSIT Six Semester Web Technology Errors correction and comments are welcome. Please feel free to give feedback for improvement of answer on email [email protected] or visit http://www.kamalguragayin.com.np for others related technologies. Model Question Write an XML and DTD to describe “weather_report” as an element and “date, location, city, state, and temperature_range” as its attributes. Ans : <?xml version="1.0" encoding="utf-8" ?> <!DOCTYPE weather_report [ <!ELEMENT weather_report EMPTY> <!ATTLIST weather_report date CDATA #REQUIRED > <!ATTLIST weather_report location CDATA #REQUIRED > <!ATTLIST weather_report city CDATA #REQUIRED > <!ATTLIST weather_report state CDATA #REQUIRED > <!ATTLIST weather_report temprature_range CDATA #REQUIRED > ] > <weather_report date="12/10/2016" location="Kathmandu" city="Bhaktapur" state="Bagmati" temprature_range="32to35F"> </weather_report> Make a simple Web site that takes information about the user and stores the information in a database. Use client-side script to validate the user input. Ans: Refer to simple insert web form video of unit 5. Question set : 2068(i) Create the HTML document with the paragraph using <p>, <h1>, <strong> for the first word for every sentence and <em> for all the capital letters. Ans: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <h1>Beautiful Kathmandu</h1> <p><strong><em>K</em>athmandu</strong> is a capital city of Nepal.<br /> <strong><em>I</em>t</strong> is wll known for it cultural diversity.</br> <strong><em>P</em>eople</strong> around the world visit kathmandu for tourism. </p> </body> </html> Design DOM for the time table of your classes in the present semester. Save at web server that is local or on the Internet. Later view it using the browser. Ans: Six Semester Day Sunday Monday Tuesday Wednesday Thursday Friday Time1 Time2 Time3 Time4 Time5 Software Web Compiler Statistics Project Lab Engineering Technology Fig: DOM of Time Table of Current Semester Above diagram is a DOM implementation of Time table of current semester. For simplicity, we display only on Sunday time table but third level and fourth level are repeated in each day. Lets write real implementation of DOM in XML file. <?xml version="1.0" encoding="utf utf-8" ?> <Six_Semester> <Day> <Sunday> <Time1>Compiler</Time1> <Time2>Software Software Engineering Engineering</Time2> <Time3>Web Technology</Time3 Time3> <Time4>Statistics</Time4>> <Time5>Project Lab</Time5 Time5> </Sunday> <Monday> <Time1>Compiler</Time1> <Time2>Software Software Engineering Engineering</Time2> <Time3>Web Technology</Time3> <Time4>Statistics</Time4> <Time5>Project Lab</Time5> </Monday> <Tuesday> <Time1>Compiler</Time1> <Time2>Software Engineering</Time2> <Time3>Web Technology</Time3> <Time4>Statistics</Time4> <Time5>Project Lab</Time5> </Tuesday> <Wednesday> <Time1>Compiler</Time1> <Time2>Software Engineering</Time2> <Time3>Web Technology</Time3> <Time4>Statistics</Time4> <Time5>Project Lab</Time5> </Wednesday> <Thursday> <Time1>Compiler</Time1> <Time2>Software Engineering</Time2> <Time3>Web Technology</Time3> <Time4>Statistics</Time4> <Time5>Project Lab</Time5> </Thursday> <Friday> <Time1>Compiler</Time1> <Time2>Software Engineering</Time2> <Time3>Web Technology</Time3> <Time4>Statistics</Time4> <Time5>Project Lab</Time5> </Friday> </Day> </Six_Semester> Let’s save in c: drive by named time_table.xml. Viewing DOM Document in Browser Just Type in Browser address bar : file:///C:/time_table.xml Question Set : 2068 (II) How does a web server link physically on the Internet? How do we navigate from one URL to another from a page displayed at a browser? Explain. Ans: Navigation in web page issimple. It use a single link tag termed as Anchor Tag <a>. By using anchor tag we can navigate from different portion of site, another web site. Generally navigation has three techniques • Internal navigation (Navigation inside site) • External Navigation (Navigate to third party site) • Intra Navigation (Navigate with in web page for easy scrolling) The following example demonstrate navigation technique in web browser. <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <a name="top"></a>this is top section <<a href="#down">go to down section</a> contents here span multiple line at least 100 lines to demonstrate intra link <a name="down"></a>this is down section <a href="#top">go to top section </a> <a href="/images/flower.jpg">Open flower Picture of site (internal Link)</a> <a href="http://www.facebook.com">Open facebook site (External Link)</a> </body> </html> Question Set: 2069 Create a small XML file designed to contain information about student performance on a module. Each student has a name, roll no, a subject mark and an exam mark. Ans: <?xml version="1.0" encoding="utf-8" ?> <performance> <student> <Name>Ram</Name> <Roll_Number>1</Roll_Number> <Subject_Mark>80</Subject_Mark> <Exam_Mark>30</Exam_Mark> </student> <student> <Name>Hari</Name> <Roll_Number>2</Roll_Number> <Subject_Mark>80</Subject_Mark> <Exam_Mark>45</Exam_Mark> </student> <student> <Name>Sita</Name> <Roll_Number>3</Roll_Number> <Subject_Mark>80</Subject_Mark> <Exam_Mark>55</Exam_Mark> </student> <student> <Name>Amit</Name> <Roll_Number>4</Roll_Number> <Subject_Mark>80</Subject_Mark> <Exam_Mark>65</Exam_Mark> </student> </performance> Using test structuring toys, create a homepage for the curriculum vitae. Save at web server that is local or on the internet. Later view it using the browser. <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Curriculum Vitae</title> </head> <body> <form id="form1" runat="server"> <h1>Curriculum Vitae</h1> <div> <br /> <table style="width:100%;"> <tr> <td>Name</td> <td>Amit Sharma</td> </tr> <tr> <td>Father Name</td> <td>Ram Kumar Sharma</td> </tr> <tr> <td>DOB</td> <td>12<sup>th</sup> OCT 1998</td> </tr> <tr> <td>Temporary Address</td> <td>Narangarh, Chitwan</td> </tr> <tr> <td>Permanent Address</td> <td>Kathmandu,Bagmati</td> </tr> <tr> <td>Marital Status</td> <td>Unmarried</td> </tr> <tr> <td> </td> <td> </td> </tr> </table> </div> </form> <table style="width:100%;"> <tr> <td>Educational Information</td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td>Degree</td> <td>Passed Year</td> <td>Percentage</td> </tr> <tr> <td>School Leaving Certificate</td> <td>2062 B.S.</td> <td>75</td> </tr> <tr> <td>+2 </td> <td>2064 B.S.</td> <td>78</td> </tr> <tr> <td>Bsc. CSIT </td> <td>Running</td> <td>N/A</td> </tr> </table> Achievement<br /> <ul> <li>First Prize on Graphic Design in INFOTEC Festival</li> <li>Second Prize on On spot Software Development Inter college Competition</li> <li>Second Prize in Swimming Competition Olympic 2014</li> </ul> </body> </html> Question Set : 2071 Develop a website that checks validity of a user during the log-in process . Assume that the login data (username and password) are already stored in a database. Use client-side script to validate the user input during login process. Ans: Refer to Login Check video on unit 5 Write an XML DTD to describe “person” as an element and “Name, address, phone-no, and Age” as it’s attributes. <?xml version="1.0" encoding="utf-8" ?> <!DOCTYPE Person [ <!ELEMENT Person EMPTY> <!ATTLIST Person Name CDATA #REQUIRED > <!ATTLIST Person Address CDATA #REQUIRED > <!ATTLIST Person Phone-No CDATA #REQUIRED > <!ATTLIST Person Age CDATA #REQUIRED > ] > <Person Name="Ram" Address="kathmandu" Phone-No ="014455445" Age="22"> </Person> Write an HTML code to display the following Ans: <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Login Form</title> </head> <body> <form id="form1"> <table> <tr> <td>User Name</td> <td> <input id="txtUserName" type="text" /></td> </tr> <tr> <td>Password</td> <td> <input id="txtPassword" type="text" /></td> </tr> <tr> <td> </td> <td> <input type="button" value="Login" /></td> </tr> </table> </form> </body> </html> Question Set : 2071 (II) Develop a simple website that asks the users to register using username, password, and email address. Store these informations in a database. Use client side script to validate the user input during registration. Ans : Refer to Insert web Form video in Unit 5 Write an XML schema to describe “address” as an element and “city, state, street and house-no” as it’s attributes. This is xml file <?xml version="1.0" encoding="utf-8" ?> <Information xmlns:xsi="www.w3.org/2001/XMLSchema-Instance" xsi:noNameSpaceSchemaLocation="Address.xsd"> <Address City="Bharatpur" State="Chitwan" Street="Mangal Road" House- No="007"></Address> </Information> Now XML Schema File <?xml version="1.0" encoding="utf-8"?> <xsd:schema xmlns:xsd="http://www.w3.or./2001.XMLSchema"> <xsd:element name="Information"> <xsd:complexType> <xsd:sequence> <xsd:element name="Address"> <xsd:complexType> <xsd:attribute name="City" type="xsd:string" use="required"></xsd:attribute> <xsd:attribute name="State" type="xsd:string" use="required"></xsd:attribute> <xsd:attribute name="Street" type="xsd:string" use="required"></xsd:attribute> <xsd:attribute name="House-No" type="xsd:string" use="required"></xsd:attribute> </xsd:complexType> </xsd:element> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd:schema> Write an HTML code to display the following : Example (a+b)2 =a2+2ab+b 2 Thank You Ans : <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> </head> <body> <table> <tr> <td><b>Example</b></td> </tr> <tr> <td>(a+b)<sup>2</sup>=a<sup>2</sup>+ 2ab + b<sup>2</sup></td> </tr> <tr> <td>Thank You</td> </tr> </table> </body> </html> Write a simple client side script to set and retrieve cookies. Setting Cookie <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script> function WriteCookie() { if (document.myform.customer.value == "") { alert("Enter saome value"); return; } cookievalue = escape(document.myform.customer.value) + ";" document.cookie = "name=" + cookievalue; document.wr("setting cookies : " + "name=" + cookie); } </script> </head> <body> <form name="myform" action=""> Enter Name:<input type="text" name="customer" /> <input type="button" value="setcookie" onclick="WriteCookie();" /> </form> </body> </html> Retriving Cookie <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script> function ReadCookie() { var allcookies = document.cookie; document.write("All cookie : " + allcookies); //get all cookies pair in an array cookiearray = allcookies.split(';'); //now take key value pair out of this array for (var i = 0; i < cookiearray.length; i++) { name = cookiearray[i].split('=')[0]; value = cookiearray[i].split('=')[1]; document.write("Key is: " + name + "and Value is " + value); } } </script> </head> <body> <form name="myform" action=""> Click the following button to se the result!! <input type="button" value="Read cookie" onclick="ReadCookie();" /> </form> </body> </html>
Enter the password to open this PDF file:
-
-
-
-
-
-
-
-
-
-
-
-