P h i l

advertisement
Philadelphia University
Faculty of Information Technology
Department of Software Engineering
Examination Key
Lecturer: Dr. Samer Hanna
Internal Examiner: Dr. Saed AlGoul
Coordinator: Dr. Samer Hanna
Special topics in Software Engineering
(0721439 ) Section 1
First Exam’s Key
Summer Session of 2014/2015
Date: Sunday, August 9 , 2015-------- Time: 50 min.
th
Q1) (5 marks)
Define and discuss the main target of:
1. Extensible Markup Language (XML).
Sol:
XML is a markup language much like HTML
XML was designed to describe data, not to display data
XML tags are not predefined. You must define your own tags
XML is designed to be self-descriptive
2. XML Schema Definitions (XSD).
Sol:
The purpose of an XML Schema is to define the legal building blocks of an XML document.
An XML Schema:
 defines elements that can appear in a document
 defines attributes that can appear in a document
 defines which elements are child elements
 defines the order of child elements
 defines the number of child elements
 defines whether an element is empty or can include text
 defines data types for elements and attributes
 defines default and fixed values for elements and attributes
3. Hypertext Markup Language (HTML).
Sol:
HTML (Hypertext Markup Language) is the set of markup symbols or codes inserted in a file intended for
display on a World Wide Web browser page. The markup tells the Web browser how to display a Web
page's words and images for the user.
4. Cascading Style Sheets (CSS).
Sol:
is a style sheet language used for describing the look and formatting of a document written in a markup
language.
5. JavaScript.
Sol:
an object-oriented computer programming language commonly used to create interactive effects within web
browsers.
Q2) (6 marks)
Supposing that you are asked to build a Web application for a certain company:
1. Write the needed HTML page to allow an employee in the company to insert his/her
Name, gender (only male or female is allowed), city (a drop down list of Amman, Irbid, Salt and Karak), age,
phone, hire date, email, and password. (5 marks)
2. Write the needed CSS to a) center b) give a width of 500 px and c) change the background color of the HTML
page in branch 1. (1 marks)
1
Sol:
1.
<form id="form1" runat="server">
<div>
<h2>Employee data</h2>
<table>
<tr>
<th>Name</th>
<td><input type="text" id="name" size="25" /></td>
</tr>
<tr>
<th>Gender</th>
<td><input type="radio" name="Gender" value="Male" />Male
<input type="radio" name="Gender" value="Female" />Female</td>
</tr>
<tr>
<th>City</th>
<td>
<select name="city">
<option value="Amman">Amman</option>
<option value="Amman">Irbid</option>
<option value="Amman">Salt</option>
<option value="Amman">Karak</option>
</select>
</td>
</tr>
<tr>
<th>Age</th>
<td>
<input type="number" id="age" />
</td>
</tr>
<tr>
<th>Phone</th>
<td>
<input type="tel" id="phone" />
</td>
</tr>
<tr>
<th>Hire date</th>
<td>
<input type="date" id="hire" />
</td>
</tr>
<tr>
<th>email</th>
<td>
<input type="email" id="email" />
</td>
</tr>
<tr>
<th>password</th>
<td>
<input type="password" id="pass" />
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="button" value="Save" style="font-weight: 700; width: 65px"
</td>
</tr>
</table>
</div>
</form>
2
/>
2.
#wrapper
{
width: 500px;
margin: auto;
background-color: lightgray;
}
Q3) (5 marks)
1. Write an XML document that stores the information of 2 employees for the same company in Q2. (2 marks)
2. Write the XSD file corresponding to the XML document in branch 1. (2 marks)
Sol.
1.
<Employees>
<Employee>
<Name>Ayman Eisa</Name>
<Gender>Male</Gender>
<City>Amman</City>
<Age>31</Age>
<Phone>079555555</Phone>
<HireDate>2014-09-01</HireDate>
<Email>abc123@hotmail.com</Email>
<password>a123456</password>
</Employee>
</Employees>
2.
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Employees">
<xs:complexType>
<xs:sequence>
<xs:element name="Employee">
<xs:complexType>
<xs:sequence>
<xs:element name="Name" type="xs:string" />
<xs:element name="Gender" type="xs:string" />
<xs:element name="City" type="xs:string" />
<xs:element name="Age" type="xs:positiveInteger" />
<xs:element name="Phone" type="xs:positiveInteger" />
<xs:element name="HireDate" type="xs:date" />
<xs:element name="Email" type="xs:string" />
<xs:element name="password" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Q4) (4 marks)
Write the needed JavaScript functions (and any needed related code) corresponding to the HTML page in Q2 that
Write the needed JavaScript functions corresponding to the HTML page in Q2 that:
1. Make sure that the inserted age of an employee is between 18 and 70, otherwise a proper alert should be
printed for the employee. (2 marks)
2. Checks that an employee inserted hire date is not greater than the current date and otherwise alert the
employee with a proper error message. (2 marks)
Sol.
1.
function checkAge() {
3
var age = document.getElementById("age").value;
if (age < 18 || age > 70)
alert("Valid age is only between 18 and 70")
}
2.
function checkDate ()
{
var hire = document.getElementById("hire").value;
var hireDate = Date.parse(hire);
var today = new Date();
if (hireDate>today)
alert("Invalide hire date");
}
4
Download