• Click below to download Unit 4 programs in pdf file: -



UNIT 4


1. Create an XML document template to describe the result of student in an
examination. The description should include the student's roll number, name, three subject names and marks, total marks, percentage, and result.

<?xml version="1.0" encoding="UTF-8"?>


<StudentResult>


 <student>


  <rollno>

   01

  </rollno>


  <name>

   Rakesh

  </name>


  <subject>

   <sub1>Science

    <marks>94</marks>

   </sub1>


   <sub2>Maths

    <marks>98</marks>

   </sub2>


   <sub3>Research

    <marks>100</marks>

   </sub3>


  </subject>


  <total>292</total>

  <percentage>97%</percentage>

  <result>PASS</result>

 </student>

 

 <student>


  <rollno>

   02

  </rollno>


  <name>

   Rahul

  </name>


  <subject>

   <sub1>Science

    <marks>95</marks>

   </sub1>


   <sub2>Maths

    <marks>80</marks>

   </sub2>


   <sub3>Research

    <marks>81</marks>

   </sub3>

</subject>


  <total>256</total>

  <percentage>85%</percentage>

  <result>PASS</result>

 </student>





2.Write program to demonstrate how to add attribute and Entity in
XML document .


<?xml version="1.0" encoding="UTF-8"?>


<person gender="female">

  <firstname>Anna</firstname>

  <lastname>Smith</lastname>

</person>


<person>

  <gender>female</gender>

  <firstname>Anna</firstname>

  <lastname>Smith</lastname>

</person>


<note date="2008-01-10">

  <to>Tove</to>

  <from>Jani</from>

</note>


<note>

  <date>

    <year>2008</year>

    <month>01</month>

    <day>10</day>

  </date>

  <to>Tove</to>

  <from>Jani</from>

</note>





3.Create External DTD declaration for BOOKs XML document.(Element type declaration)


<?xml version="1.0" encoding="UTF-8"?>


<!DOCTYPE book [

<!ENTITY nbsp "&#xA0;">

<!ENTITY writer "Writer: A. P. J. Abdul Kalam and Arun Tiwari">

<!ENTITY copyright "Copyright: !!!!">

]>


<note>

<heading>Wings of Fire</heading>

<body>Don't forget to read this book!</body>

<footer>&writer;&nbsp;&copyright;</footer>

</note>




4.Write a program to describe Empty, Any and Mixed content in DTD.


<?xml version = "1.0" encoding = "UTF-8" ?>


<!DOCTYPE address [

   <!ELEMENT address (#PCDATA|name)*>

   <!ELEMENT name (#PCDATA)>

]>


<address>

   Here's Mixed content in DTD

   <name>

      BCA 4 GU

   </name>

</address>


<!DOCTYPE address [

   <!ELEMENT address ANY>

]>


<address>

   Here's Any in DTD

</address>




5.Write a program to describe Attribute declaration in DTD.


<?xml version="1.0"?>


<!DOCTYPE empinfo [

    <!ELEMENT empinfo (employee)>


    <!ELEMENT employee (name, designation, email)>

    <!ATTLIST employee id CDATA #REQUIRED>


    <!ELEMENT name (#PCDATA)>

    <!ATTLIST name from CDATA #IMPLIED>


    <!ELEMENT designation (#PCDATA)>

    <!ATTLIST designation discipline CDATA #FIXED "Web developer">


    <!ELEMENT email (#PCDATA)>

    <!ATTLIST email domain CDATA "personal">  

]>


<empinfo>

    <employee id="1">

        <name>Bhavik Tiwari</name>

        <designation>Senior Engineer</designation>

        <email>bhaviktiwari@gmail.com</email>

    </employee>

    <employee id="2">

        <name from="CA">Bhavik Tiwari</name>

        <designation discipline="DBA">Senior Engineer</designation>

        <email>bhaviktiwari@gmail.com</email>

    </employee>

</empinfo>