Advertisement
sgbtechsoluation

WT ASS 7-8-9

Jan 18th, 2022
851
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 16.89 KB | None | 0 0
  1. 7. Development of XML file and write a DTD to validate the XML file and display the XML document by applying presentation styles using CSS and XSLT.
  2.  
  3. 1.
  4. a Create a DTD for kannada movies CD collection to store one or more movie information., Where each movie element has the child elements Movie_name, director, actor, actress and producer. Movie_name has attribute relased_year and must have value. Some movies are directed by more than one director and producers. Actor and actress element has attribute type to represent the role played by the actor/actress i.e   lead role or side role. Default value is lead role. Define an entity for the director who directed most of the movies in the collection.
  5.  
  6.  
  7.  
  8. 7a
  9. xml doc
  10. <?xml version="1.0" encoding="UTF-8"?>
  11.  <?xml-stylesheet type="text/css" href="7a.css"?>
  12. <!DOCTYPE movie SYSTEM "7aDTD.dtd">
  13.  
  14. <collection>
  15.     <movie>
  16.         <Movie_name relased_year="2019">Enternals</Movie_name><br/>
  17.         <director>Rouso's</director>
  18.         <actor role="lead role">Harry Styles</actor>
  19.         <actress role="lead role">Anjolina jolie</actress>
  20.         <producer>Marvel Studios</producer>
  21.         <producer>kevin</producer>
  22.     </movie>
  23.     <movie>
  24.         <Movie_name relased_year="2018">ShangChi</Movie_name>
  25.         <director>Simu luie</director>
  26.         <actor role="lead role">tony leung</actor>
  27.         <actress role="side role">awkwafina</actress>
  28.         <producer>Marvel Studios</producer>
  29.         <producer>kevin</producer>
  30.     </movie>
  31.     <movie>
  32.         <Movie_name relased_year="2015">Iron-man</Movie_name>
  33.         <director> john par</director>
  34.         <actor role="lead role">Robert Downey Jr.</actor>
  35.         <actress role="lead role">Pepper Pots</actress>
  36.         <producer>Marvel Studios</producer>
  37.         <producer>kevin</producer>
  38.     </movie>
  39. </collection>
  40.  
  41. b. Create an XML document with at least three instances of the movie element defined in DTD. Display raw XML document
  42.  
  43.  
  44. xml dtd
  45. <?xml version="1.0" encoding="UTF-8"?>
  46. <!--
  47. To change this license header, choose License Headers in Project Properties.
  48. To change this template file, choose Tools | Templates
  49. and open the template in the editor.
  50. -->
  51.  
  52. <!--
  53.    TODO define vocabulary identification data
  54.    PUBLIC ID  : -//vendor//vocabulary//EN
  55.    SYSTEM ID  : http://server/path/__NAME__
  56. -->
  57.  
  58. <!-- TODO define your own vocabulary/syntax. Example follows:  -->
  59. <!ELEMENT collection(movie+)>
  60. <!ELEMENT movie(Movie_name, director+, actor, actress, producer+)>
  61. <!ELEMENT Movie_name (#PCDATA)>
  62. <!ELEMENT director (#PCDATA)>
  63. <!ELEMENT actor (#PCDATA)>
  64. <!ELEMENT actress (#PCDATA)>
  65. <!ELEMENT producer (#PCDATA)>
  66. <!ATTLIST Movie_name relased_year CDATA #REQUIRED>
  67. <!ATTLIST actor role CDATA "lead role">
  68. <!ATTLIST actress role CDATA "lead role">
  69.  
  70.  
  71. c. Create a CSS style sheet for the above XML document to display the movie name in red colour with font-size 4 and in bold and background colour yellow. Each child element of movie must have background colour pink and font colour blue and font-size 2 and style italic. Each element must have block display
  72.  
  73. xml css
  74. Movie_name{
  75.     display:block;
  76.     color: red;
  77.     font-size: 2em;
  78.     font-size:bold;
  79.     background-color: yellow;
  80.    
  81. }
  82. movie{
  83.    display:block;
  84.     background-color: pink;
  85.     color: blue;
  86.     font-size: 1.5em;
  87.     font-style: italic;
  88.     font-size: bold;
  89.  
  90. }
  91. collection{
  92.     white-space: pre;
  93. }
  94.  
  95.  
  96.  
  97.  
  98. 2.
  99. a. Design an XML document that stores information about Indian popular cricket players. Information for each cricket player must include their name (include three parts of name), runs scored and wickets taken in one day matches. XML document must store at least three players information.
  100.  
  101. 7b
  102. xml
  103. <?xml version="1.0" encoding="UTF-8"?>
  104. <?xml-stylesheet type="text/xsl" href="7bxls.xsl" ?>
  105. <players>
  106.     <player>
  107.         <f_name>Rahul</f_name>
  108.         <m_name>A</m_name>
  109.         <l_name>Dhrawid</l_name>
  110.         <runs>11753-ODI</runs>
  111.         <wickets>19-ODI</wickets>
  112.     </player>
  113.     <player>
  114.         <f_name>Virat</f_name>
  115.         <m_name>-</m_name>
  116.         <l_name>Kohli</l_name>
  117.         <runs>15169-ODI</runs>
  118.         <wickets>15-ODI</wickets>
  119.     </player>
  120.     <player>
  121.         <f_name>Anil</f_name>
  122.         <m_name>G</m_name>
  123.         <l_name>Kumble</l_name>
  124.         <runs>5205-ODI</runs>
  125.         <wickets>35-ODI</wickets>
  126.     </player>
  127. </players>
  128.  
  129. b. Create an XSLT style sheet to display the players information in tabular form. Each players information must be displayed in different colour in table. Table must contain heading Indian popular cricket players details with font property red colour, bold and size 3.
  130. xls
  131. <?xml version="1.0" encoding="UTF-8"?>
  132. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  133.     <xsl:output method="html"/>
  134.     <xsl:template match="/players">
  135.         <html>
  136.             <head>
  137.                 <title>Indian-Cricketers-Players</title>
  138.             </head>
  139.             <body>
  140.                 <h1 style="font-size:5em;color:red" align="center">Indian popular cricket players </h1>
  141.                 <table border="1" align="center">
  142.                     <tr>
  143.                         <th>First_Name</th>
  144.                         <th>Middle_Name</th>
  145.                         <th>Last_Name</th>
  146.                         <th>Runs</th>
  147.                         <th>Wickets</th>
  148.                     </tr>
  149.                     <xsl:for-each select="player">
  150.                         <tr>
  151.                             <td style="background-color:black;color:greenyellow;"><xsl:value-of select="f_name"/></td>  
  152.                             <td style="background-color:orange;color:blue;"><xsl:value-of select="m_name"/></td>  
  153.                             <td style="background-color:green;color:yellow;"><xsl:value-of select="l_name"/></td>
  154.                             <td style="background-color:yellow;color:black;"><xsl:value-of select="runs"/></td>
  155.                             <td style="background-color:red;color:white;"><xsl:value-of select="wickets"/></td>
  156.                         </tr>  
  157.                     </xsl:for-each>
  158.                 </table>
  159.             </body>
  160.         </html>
  161.     </xsl:template>
  162. </xsl:stylesheet>
  163.  
  164.  
  165. 8. PHP program on form data handling
  166. Design the HTML page to create a form with the following capabilities
  167. a.  Textbox to collect the user’s name
  168. b.  Three textboxes, one each for the following items,
  169. 1.   Apple (100 per kg)
  170. 2.  Orange (80 per kg)
  171. 3.   Banana (50 per kg)
  172. c.  A collection of three radio buttons that are labelled as follows
  173. i.visa
  174. ii.Master card
  175. iii. Discover
  176. d.  A submit and clear button
  177.  user must enter the quantity wiling to purchase in respective textbox.  Entered user name must contain only alphabetics and quantities entered in the textbox must be number. Validate the data for onblur event of the textboxes.
  178. On submitting the form, a PHP script must collect the entered data from the form and compute the total cost for fruit purchase. PHP script must inform the buyer total cost and details of purchased fruits by displaying in tabular form.
  179.  
  180. 8a
  181. index.php
  182. <!DOCTYPE html>
  183. <!--
  184. Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
  185. Click nbfs://nbhost/SystemFileSystem/Templates/Project/PHP/PHPProject.php to edit this template
  186. -->
  187. <html>
  188.     <head>
  189.         <meta charset="UTF-8">
  190.         <title>Assignment 8</title>
  191.         <style>
  192.             body{
  193.                 margin: 200px 200px;
  194.             }
  195.         </style>
  196.         <script type="text/javascript">
  197.             cost1=0;
  198.             cost2=0;
  199.             cost3=0;
  200.             function displaycost(i)
  201.             {
  202.                
  203.                if(i===1)
  204.                {
  205.                    x=document.getElementById("id2");
  206.                    d=x.value;
  207.                    if(d>=0)
  208.                    {
  209.                      alert("The Cost of Apple will be : "+(d*100)+" Rs");
  210.                      cost1=d*100;    
  211.                    }
  212.                    else
  213.                    {
  214.                      alert("Invalid data");  
  215.                      x.value=0;
  216.                    }
  217.                    
  218.                }
  219.                else if(i===2)
  220.                {
  221.                    x=document.getElementById("id3");
  222.                    d=x.value;
  223.                    if(d>=0)
  224.                    {
  225.                        alert("The Cost of Orange will be : "+(d*80)+" Rs");
  226.                        cost2=d*80;
  227.                    }
  228.                    else
  229.                    {
  230.                         alert("Invalid data");  
  231.                         x.value=0;
  232.                    }
  233.                    
  234.                }
  235.                else if(i===3)
  236.                {
  237.                    x=document.getElementById("id4");
  238.                    d=x.value;
  239.                    if(d>=0)
  240.                    {
  241.                      alert("The Cost of banana will be : "+(d*50)+" Rs");
  242.                      cost3=d*50;  
  243.                    }
  244.                    else
  245.                    {
  246.                        alert("Invalid data");  
  247.                         x.value=0;
  248.                    }
  249.                    
  250.                }
  251.             }
  252.             function checkname()
  253.             {
  254.                 x=document.getElementById("id1");
  255.                 d=x.value;
  256.                 if(d.search(/^[A-Za-z]+$/)!==-1)
  257.                 {
  258.                     alert("Correct Name :Go forward ");
  259.                 }
  260.                 else
  261.                 {
  262.                     alert("please Reenter the name ");
  263.                     x.value="";
  264.                 }
  265.                
  266.  
  267.             }
  268.             function checkall()
  269.             {
  270.                 a=document.getElementById("id1").value;
  271.                 b=document.getElementById("id2").value;
  272.                 c=document.getElementById("id3").value;
  273.                 d=document.getElementById("id4").value;
  274.                 x=document.getElementsByName("paymode");
  275.                 flag=0;
  276.                 for(i=0;i<x.length;i++)
  277.                {
  278.                    if(x[i].checked)
  279.                    {
  280.                        flag=1;
  281.                        break;
  282.                    }
  283.                }
  284.                if(a!=="" && b>=0 && c>=0 && d>=0 && flag)
  285.                {
  286.                    alert("submitting data please wait");
  287.                     return true;
  288.                 }
  289.                 else
  290.                 {
  291.                     if(!flag)
  292.                     {
  293.                         alert("please select payment method");
  294.                     }
  295.                     else
  296.                         alert("Please Enter Name and items correctly");
  297.                     return false;
  298.                 }
  299.                
  300.             }
  301.            
  302.         </script>
  303.         <style>
  304.             body{
  305.                 background-color:#ffdddd;
  306.                 margin-top:150px;
  307.             }
  308.             div{
  309.                 padding:20px 0px 10px 0px;
  310.                 border:1px solid blue;
  311.                 box-shadow: 10px 10px 20px 5px;
  312.             }
  313.             input{
  314.                 border:1px solid grey;
  315.                 margin:7px;
  316.                
  317.             }
  318.            
  319.            
  320.         </style>
  321.     </head>
  322.     <body>
  323.         <div>
  324.     <center>
  325.         <form action="http://localhost/PhpProject1/nextpage.php" method="POST"  onsubmit="checkall()">
  326.             <label id='un'>USERNAME :</label>
  327.             <input type="text" id="id1" name="username" size="25" placeholder="USER NAME" onblur="checkname()"/>
  328.             <h2>ENTER THE NUMBER OF ITEMS PER KG FOR BELOW FRUITS</h2>
  329.             <label>APPLE :</label>
  330.             <input type="number" id="id2" name="apple"  size="25" onblur="displaycost(1)"/>
  331.             <br>
  332.             <label>Orange :</label>
  333.             <input type="number" id="id3" name="orange"  size="25" onblur="displaycost(2)"/>
  334.             <br>
  335.             <label>Banana :</label>
  336.             <input type="number" id="id4" name="banana" size="25" onblur="displaycost(3)"/>
  337.             <br>
  338.             <h2>Select Payment Type</h2>
  339.             <label>Visa :</label>
  340.             <input type="radio" id="id5" name="paymode" value="visa"/><br>
  341.             <label>Master card :</label>
  342.             <input type="radio" id="id6" name="paymode" value="master card"/><br>
  343.             <label>Discover :</label>
  344.             <input type="radio" id="id7" name="paymode" value="discover"/><br>
  345.             <br>
  346.             <input type="submit" value="Submit" />
  347.             <input type="reset"/>
  348.         </form>
  349.     </center>
  350. </div>
  351. </body>
  352. </html>
  353.  
  354. nextpage.php
  355. <html>
  356.     <body>
  357.     <center>
  358.        
  359.         <?php
  360.        $username = $_POST['username'];
  361.        print("<h1>Dear User: $username</h1>");
  362.         ?>
  363.         <h2>The details of the purchsed Items are</h2>
  364.         <table border="2">
  365.             <tr>
  366.                 <th></th>
  367.                 <th>Apple</th>
  368.                 <th>Orange</th>
  369.                 <th>Banana</th>
  370.                 <th>Paymode</th>
  371.             </tr>
  372.             <?php
  373.            $apple = $_POST['apple'];
  374.            $orange = $_POST['orange'];
  375.            $banana = $_POST['banana'];
  376.            $paymode = $_POST['paymode'];
  377.            $apple_cost = $apple * 100;
  378.            $orange_cost = $orange * 80;
  379.            $banana_cost = $banana * 50;
  380.            $total = $apple_cost + $orange_cost + $banana_cost;
  381.            print("<tr>");
  382.             print("<th>Items Purchased</th>");
  383.             print("<td>$apple</td>");
  384.             print("<td>$orange</td>");
  385.             print("<td>$banana</td>");
  386.             print("<td>$paymode</td>");
  387.             print("</tr>");
  388.             print("<tr>");
  389.             print("<th>Total</th>");
  390.             print("<td>$apple_cost</td>");
  391.             print("<td>$orange_cost</td>");
  392.             print("<td>$banana_cost</td>");
  393.             print("<td>$total</td>");
  394.             print("</tr>");
  395.             ?>
  396.         </table>
  397.     </center>
  398. </body>
  399. </html>
  400.  
  401. 9. a. PHP program to demonstrate Cookie creation, display and deletion.
  402. Design HTML page to accept cookie name and value using textbox. On submission of form PHP script must display a cookie is created and add two buttons to php script with caption display cookie and delete cookie.  submission of display cookie button should display the cookie information by fetching the cookie value. Submission of delete cookie button must delete the cookie and display a message cookie is deleted.  
  403. b. PHP program to demonstrate session.
  404.  Write a PHP script to display the number of times a page is requested by creation a session.
  405.  
  406.  
  407.  
  408. 9a
  409. main.php
  410.  
  411. <html>
  412.     <head>
  413.     </head>
  414.     <body>
  415.     <center>
  416.         <h1>ENTER COOKIE DETAILS</h1>
  417.         <form action="http://localhost/PhpProject1/9a_cookie.php" method="POST">
  418.             <label>Cookie Name</label>
  419.             <input type="text" name="cookiename" size="25"/><br>
  420.             <label>Cookie Value</label>
  421.             <input type="text" name="cookievalue" size="25"/><br>
  422.             <input type="submit" value="Submit"/>
  423.             <input type="reset"/>
  424.         </form>
  425.     </center>
  426.     </body>
  427. </html>
  428.  
  429. cookie creation page
  430.  
  431. <html>
  432.     <body>
  433.     <center>
  434.         <?php
  435.        $cookiename = $_POST['cookiename'];
  436.        $cookievalue = $_POST['cookievalue'];
  437.        setcookie("name", "$cookiename", time() + 86400);
  438.        setcookie("value", "$cookievalue", time() + 86400);
  439.        ?>
  440.         <h1>The Cookie is Created</h1>
  441.         <form action="http://localhost/PhpProject1/d_cookie.php" method="get">
  442.             <input type="submit" value="display cookie"/>
  443.         </form>
  444.         <form action="http://localhost/PhpProject1/del_Cookie.php" method="get">
  445.             <input type="submit" value="Delete cookie"/>
  446.         </form>
  447.     </center>
  448. </body>
  449. </html>
  450. display cookie
  451.  
  452. <html>
  453.     <body>
  454.     <center>
  455.         <h1>The Cookie Data is</h1>
  456.         <?php
  457.        if(isset($_COOKIE['name']) && isset($_COOKIE['value']))
  458.        {
  459.            $cookiename1 = $_COOKIE['name'];
  460.            $cookievalue1 = $_COOKIE['value'];
  461.            print("<h3>Cookie Name : $cookiename1<h3>");
  462.             print("<h3>Cookie Value : $cookievalue1<h3>");
  463.         }
  464.         else{
  465.             print("<h3>Cookie Is Already Deleted<h3>");
  466.         }
  467.        
  468.         ?>
  469.     </center>
  470. </body>
  471. </html>
  472. delete cookie
  473. <html>
  474.     <body>
  475.     <center>
  476.         <h1>The Cookie Data is Deleted</h1>
  477.         <?php
  478.        $cookiename = $_COOKIE['name'];
  479.        $cookievalue = $_COOKIE['value'];
  480.        setcookie("name", "$cookiename", time() - 10);
  481.        setcookie("value", "$cookievalue", time() - 10);
  482.        ?>
  483.     </center>
  484. </body>
  485. </html>
  486.  
  487.  
  488.  
  489.  
  490.  
  491.  
  492. 9b
  493. <?php
  494.  
  495. session_start();
  496.  
  497. if(isset($_SESSION['views']))
  498.    $_SESSION['views'] = $_SESSION['views']+1;
  499. else
  500.    $_SESSION['views']=1;
  501.      
  502. echo"views = ".$_SESSION['views'];
  503.  
  504. ?>
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511.  
  512.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement