Sunteți pe pagina 1din 6

XML practical file

Lab 1:
1. Create an XML document template to describe the results of students in an examination. The description should include the
student’s roll number, name, three subject names and marks, total marks, percentage, and result.
<student>
<name>Ishu Khanchi</name>
<rno>80</rno>
<subjectname>
<sub1>Maths</sub1>
<sub2>Physics</sub2>
<sub3>Chemistry</sub3>
</subjectname>
<subjectmarks>
<marks1>77</marks1>
<marks2>78</marks2>
<marks3>80</marks3>
</subjectmarks>

<total>70+77+78</total>
<percentage>[(70+77+78)/3]*100</percentage>
<result>The final result is displayed.</result>
</student>

3. With reference to the above question, describe the various XML terms found there.

XML: Extensible Markup Language. A standard for building markup languages.


attribute: A name and its value which are included inside an XML tag.
child: An XML element located inside another XML element.
content model: In XML, the expression specifying what elements and data are allowed within an element.
element: A block of text in an XML document made up of a start and end tag, and the content between the tags. Empty tags are also elements.
For example, <price>$12.60</price> and <price/> are both elements..
parent: An XML element which contains another XML element. The XML element contained by the parent is the child element.
root element: The element that contains all of the other elements in an XML document.
schema: A technology-neutral term for the definition of the structure of an XML document.
valid XML: XML that meets the constraints defined by its Document Type Declaration.
well-formed XML: An XML document is well-formed if there is one root element, and all its child elements are nested within each other. Start
tags must have end tags, and each empty tag must be designated as such with a trailing slash (<emptyTag/>). Also all attributes must be
quoted, and all entities must be declared.

Lab 2:

3. Suppose we want to store information regarding employees in the following format in XML. Show such a file with one example.

Employee ID Numeric 5 positions

Employee Name Alphanumeric 30 positions

Employee Department Alphanumeric 3 positions

Role Alphanumeric 20 positions

Manager Alphanumeric 30 positions

<company>
<Employee>
<Employee_ID type='numeric'>1</Employee_ID>
<Employee_Name type='Alphanumeric'>Anupriya</Employee_Name>
<Employee_Dept type='Alphanumeric'>Chemical</Employee_Dept>
<Role type='Alphanumeric'>Advisor</Role>
<Manager type='Alphanumeric'>XYZ</Manager>
</Employee>
<Employee>
<Employee_ID type='numeric'>2</Employee_ID>
<Employee_Name type='Alphanumeric'>Poulomi</Employee_Name>
<Employee_Dept type='Alphanumeric'>Metallurgy</Employee_Dept>
<Role type='Alphanumeric'>Analyst</Role>
<Manager type='Alphanumeric'>XYZ</Manager>
</Employee>
<Employee>
<Employee_ID type='numeric'>3</Employee_ID>
<Employee_Name type='Alphanumeric'>Anjali</Employee_Name>
<Employee_Dept type='Alphanumeric'>science</Employee_Dept>
<Role type='Alphanumeric'>consultant</Role>
<Manager type='Alphanumeric'>XYZ</Manager>
</Employee>
</company
4. Suppose our banking application allows the user to perform an online funds transfer. This application generates an XML message, which
needs to be sent to the database for actual updates. Create such a sample message, containing the following details:

Transaction reference number Numeric 10 positions

From account Numeric 12 positions

To account Numeric 12 positions

Amount Numeric 5 positions (No fractions are allowed)

Date and Time Numeric Timestamp field

<bank>
<emp1>
<transaction_ref_no type="numeric">111</transaction_ref_no>
<from type="numeric">32217846083</from>
<to type="numeric">3425897659089</to>
<amount type="numeric">12333</amount>
<date type="timestamp">11-11-11 12:23:40</date>
</emp1>

<emp2>
<transaction_ref_no type="numeric">112</transaction_ref_no>
<from type="numeric">32217846044</from>
<to type="numeric">3423765868754</to>
<amount type="numeric">134563</amount>
<date type="timestamp">11-11-16 06:25:40</date>
</emp2>

<emp3>
<transaction_ref_no type="numeric">113</transaction_ref_no>
<from type="numeric">7459765446044</from>
<to type="numeric">989048768754</to>
<amount type="numeric">145563</amount>
<date type="timestamp">01-01-16 03:25:40</date>
</emp3>
</bank>

5. Consider that we want to capture information about a salesperson. Capture this information in an XML format.

<sales>

<s1>
<name>Rajesh</name>
<Address>NHGCLUGL</Address>
<phone>7830459568</phone>
<product_no>12</product_no>
<product_name>pens</product_name>
<quantity>500</quantity>
</s1>

<s2>
<name>Brijesh</name>
<Address>kjdhfiulgh</Address>
<phone>78750666645</phone>
<product_no>13</product_no>
<product_name>pensils</product_name>
<quantity>500</quantity>
</s2>

<s2>
<name>Hirani</name>
<Address>jefhlughorgh</Address>
<phone>478565896</phone>
<product_no>14</product_no>
<product_name>rulers</product_name>
<quantity>300</quantity>
</s2>
</sales>
Lab3:
1. Create library.xml file with the following constraints:
a. Library has book and member details
i. More than one book and member is possible

b. Books has the following elements


i. id
ii. name
iii. author
iv. ISBN

· id, name, author are mandatory fields. More than one author and ISBN number can be possible.

c. Member has the following elements


i. id
ii. password
iii. name
iv. age
v. email
vi. phoneNumber
vii. panNumber
viii. passportNumber

· id, password, name, age fields are mandatory


· email is optional. maximum one email is allowed
· more than one phoneNumber is allowed.
· (passportNumber, panNumber) either this or that is allowed only once
· hightlight emailId, name and author with different color

Create the XML document for at least 10 books and 10 members. Check the XML document for well formness.
<library>
<book>
<id>1</id>
<name>Graphics with OpenGL</name>
<author>Baker</author>
<ISBN>894760</ISBN>
</book>

<book>
<id>2</id>
<name>Computer System Architecture</name>
<author>Morris</author>
<ISBN>3487</ISBN>
</book>

<book>
<id>3</id>
<name>The discovery of India</name>
<author>Pt. Jawaharlal Nehru</author>
<ISBN></ISBN>
</book>

<book>
<id>4</id>
<name>uflerge</name>
<author>rkjghrliu</author>
<ISBN>7775</ISBN>
</book>

<book>
<id>5</id>
<name>erherile</name>
<author>uhrgiluhkd</author>
<ISBN>59879</ISBN>
</book>

<book>
<id>6</id>
<name>hklgr</name>
<author>krejlgrj</author>
<ISBN>8954978</ISBN>
</book>

<book>
<id>7</id>
<name>gfkkhusdrd</name>
<author>uigulhkj</author>
<ISBN>8748</ISBN>
</book>

<book>
<id>8</id>
<name>hlflkjh</name>
<author>jeklhjkfd</author>
<ISBN>63844</ISBN>
</book>

<book>
<id>9</id>
<name>fkhelfnf</name>
<author>krhehjhje</author>
<ISBN>43768</ISBN>
</book>

<book>
<id>10</id>
<name>lkfejefkl</name>
<author>khlfk</author>
<ISBN>8474</ISBN>
</book>

<member>
<id></id>
<password></password>
<name></name>
<age></age>
<email></email>
<phone></phone>
<pan></pan>
<pass></pass>
</member>

<member>
<id></id>
<password></password>
<name></name>
<age></age>
<email></email>
<phone></phone>
<pan></pan>
<pass></pass>
</member>
<member>
<id></id>
<password></password>
<name></name>
<age></age>
<email></email>
<phone></phone>
<pan></pan>
<pass></pass>
</member>
<member>
<id></id>
<password></password>
<name></name>
<age></age>
<email></email>
<phone></phone>
<pan></pan>
<pass></pass>
</member>
<member>
<id></id>
<password></password>
<name></name>
<age></age>
<email></email>
<phone></phone>
<pan></pan>
<pass></pass>
</member>
<member>
<id></id>
<password></password>
<name></name>
<age></age>
<email></email>
<phone></phone>
<pan></pan>
<pass></pass>
</member>

<member>
<id></id>
<password></password>
<name></name>
<age></age>
<email></email>
<phone></phone>
<pan></pan>
<pass></pass>
</member>
<member>
<id></id>
<password></password>
<name></name>
<age></age>
<email></email>
<phone></phone>
<pan></pan>
<pass></pass>
</member>
<member>
<id></id>
<password></password>
<name></name>
<age></age>
<email></email>
<phone></phone>
<pan></pan>
<pass></pass>
</member>
<member>
<id></id>
<password></password>
<name></name>
<age></age>
<email></email>
<phone></phone>
<pan></pan>
<pass></pass>
</member>
<member>
<id></id>
<password></password>
<name></name>
<age></age>
<email></email>
<phone></phone>
<pan></pan>
<pass></pass>
</member>

S-ar putea să vă placă și