Sei sulla pagina 1di 9

XML Simplified Assignments

Aptech Ltd Version 1.1 Page 1 of 9


XML Simplified Assignments

Table of Contents

S# Session Page No.


1. Introduction to XML 3
2. Namespaces 4
3. DTDs 5
4. XML Schema 6
5. Stylesheets 7
6. XSL and XSLT 8
7. More on XSLT 9

Aptech Ltd Version 1.1 Page 2 of 9


XML Simplified Assignments

Intr oduction to XM L
Sr. No. Assignment Question
1 Assume that data for a book catalogue is available. An XML document for the
book catalogue with the following elements: name, author, pages, price, and table
of contents are to be created. The price element should also specify whether the
book is accompanied with a CD or DVD or both.

Create an XML document for the above mentioned catalogue displaying data for
about 10 books.

Aptech Ltd Version 1.1 Page 3 of 9


XML Simplified Assignments

Namespaces
Sr. No. Assignment Question
1 Global Express is USAs leading integrated air express carrier and premium
logistics-services provider. They have the most extensive domestic network
covering over 20 locations.
Every office of theirs has to maintain a record of the letters dispatched on a day-
to-day basis. These records are stored in hard copies which make them prone to
damage or loss of data. To overcome this possibility, the company has decided to
store the information in computers and the data is to be transferred using XML.
Create an XML file called Order.xml using the following element names. The
specifications are as follows:
Invoice
Order: (Should have an order number attribute)

o Customer Name
o Address
o Order id
o Total Price
Cod:
o Shipping Address
o Shipping method (air or ground)
o Shipping total
Account: (State if the account is active or not. The default should be
active.)
o Customer ID
o Invoice period
Shipping info
o Ship date
o Billing Address (This element should be optional)
Description
o Description should be one of the product

Keeping into considerations that there are five regional offices and five different
set of data is to be merged at the Head office, duplication of data is a huge
possibility. For example, Customer Name in New York can match a customer
name in a Chicago. To differentiate the data when it is merged, use namespaces
to declare elements. Use entity declarations wherever necessary in the XML
document.

Aptech Ltd Version 1.1 Page 4 of 9


XML Simplified Assignments

DTDs
Sr. No. Assignment Question
1 Local Courier Service Simulation
The local courier service XYZ has branches all over the country. Every region has
one regional office that coordinates with the branches in that region. Couriers
from the branches are collected and sent to the regional office for sorting and
dispatch. Similarly, incoming couriers are sorted at the regional office and sent to
the branches.
Every regional office has to maintain a record of the couriers it receives from the
branches and of couriers it sends to the branches. Similarly, it needs to maintain
records of couriers it sends to other regional offices and receives from other
regional offices.
The officials no longer wish to transfer these records as hard copy, which makes it
prone to so many possibilities of being damaged or corrupted. They have decided
to employ data operators who will feed the information into computers and
transfer the data using XML.
Now, the foreseen problem is multiple data operators entering similar data using
XML. To resolve the inconsistency that could occur due to operators developing
their own tags officials have requested for standardization of the tags to be used.
Based on these existing conditions, write a DTD for the above problem. Once the
DTD is finalized, test the DTD with fake data. Test both internal and external
DOCTYPE declarations.
Make sure tags for addresses are adequate and capable enough to hold any form
of address data (Hint: Some addresses have villas while some buildings and
apartment number. Look for all possible kinds of addresses and then create the
element). The format for how the data will be structured too is open-ended but
should be optimal for the above purpose.
(Hint: Make use of the different element declarations. The DTD should take care
of information such as branch/regional details, courier details (from and to
details), date of receipt of couriers or dispatch of couriers, transportation/shipping
details, and so on)

Aptech Ltd Version 1.1 Page 5 of 9


XML Simplified Assignments

XML Schema
Sr. No. Assignment Question
1 An XML file will be used to represent data collected from an online sales Web
site. This site sells different kinds of office supplies. Create an XML file that
captures the following information:
Item Name - examples include paper, clips, rubber bands, pens, and so
on.
Item Inventory ID - examples include F12333, Z55553, and so on -
restrictions are that the Inventory ID must begin with a letter followed by
5 digits.
Item Unit Price - examples include 4.553, 22.33, and so on - must be a
double and no less than 1.00.
Count in Stock - whole number no less than 0.
Stock Bin - this is where the item is located in the stock room - examples
include B786, B345, and so on. - Restrictions are that this must be the
letter B followed by three digits.

1. Create a Schema file that clearly defines the tags, their elements, data
types and implements the restrictions indicated.
2. Create an XML file that represents this data. Use some sample data. Make
sure the XML file is well formed.
3. Make sure the Schema file works with the XML file.

Aptech Ltd Version 1.1 Page 6 of 9


XML Simplified Assignments

Stylesheets
Sr. No. Assignment Question
1 University Result Simulation
A university desires to display the exam results of its students for all semesters
using XML and CSS. The results should be displayed in the figure.

At the top of the screen, the name of the university should be displayed in white
on black background with a border. Then on the next line(s) the address of the
university should be displayed in the same manner except that the border need
not be so prominent.
The results should be displayed in the following manner. First the Semester
number should be displayed in white over a black background. Next, a students
name should follow in white over grey background. The students name should
follow by a block of subject names and the students grades in those subjects. All
the students, for the respective semester, should be represented in the following
manner. The next semesters details should follow the first one and so on.
Create the XML and CSS document for the same. Simulate data for about fifteen
students (three semesters five students each).

Aptech Ltd Version 1.1 Page 7 of 9


XML Simplified Assignments

XSL and XSLT


Sr. No. Assignment Question
1 Real estate scenario
A local software company Navigator Ltd. deals with the maintenance of data about
locations and finance of different showrooms. The company collects the
information about the various branches of big showrooms and stores it in its
database.
The information includes the number of branches, the amount the branch has to
pay as rent, the amount of money that the branch has taken as a loan, the
number of people working in that branch and so on.
Every showroom has to register these details in a database. Since it is highly
impossible to maintain a record of each and every branch in a country, the IT hub
of the showroom decide to outsource it to this software company.
There is a sudden audit in the showroom and the data abstractors of the software
company were made to give the following details on an urgent basis:
Divide the number of people according to the batches that have joined.
The rent that each individual branch pays to their respective landlord.
The daily allowance given to the people in all the branches according to the
seniority.
Now, prepare a report and display the output in XML using XSL as the style sheet.
After the transformation is done, display the records of each section separately.
As these results are to be shown to the auditors directly, ensure that proper and
clear formatting is done.
Ensure that the data is displayed in a complete formal manner.
Note: Make use of <xsl:template>, <xsl:select>, <xsl:value-of>, <xsl:for-
each>, <xsl:sort>.

Aptech Ltd Version 1.1 Page 8 of 9


XML Simplified Assignments

Mor e on XSLT
Sr. No. Assignment Question
1 Alveira Technologies, a business process outsourcing firm based in San Jose,
was storing details of its employees in XML format. Suddenly the management
decided to migrate all its data to HTML format. An application needs to be created
that will design and implement an XSLT stylesheet to transform the XML content
to HTML format. Make use of XPath and XSLT to achieve the same.

--- End of Assignments ---

Aptech Ltd Version 1.1 Page 9 of 9

Potrebbero piacerti anche