Professional Documents
Culture Documents
NAME: M BABAR
SEMESTER: II
CODE:
Q1.
+------------------------+ +-----------------------+
| Sender | | Receiver |
+------------------------+ +-----------------------+
| |
Application Layer Application Layer
| |
+------------------------+------------------------+
| TCP | TCP |
+------------------------+------------------------+
| IP | IP |
+------------------------+------------------------+
| Network | Network |
+------------------------+------------------------+
| Link/Physical | Link/Physical |
+------------------------+------------------------+
b) Why are Logical Character Tags used? Explain any five Logical Character Tags with
suitable example.
Logical character tags are used to provide additional semantic information about specific characters or
sequences of characters within a text. These tags help in specifying the role or meaning of the tagged
characters, which can be beneficial for various applications such as natural language processing, text
analysis, and machine learning.
Five commonly used logical characters are as follow –
1. Part-of-Speech (POS) Tag: POS tags represent the grammatical category or syntactic role of a
word in a sentence. They help in identifying nouns, verbs, adjectives, adverbs, etc. Example: In
the sentence "The cat is sleeping," the POS tags could be "DT" (determiner) for "The," "NN"
(noun) for "cat," "VBZ" (verb) for "is," and "VBG" (verb, gerund or present participle) for
"sleeping."
2. Named Entity Tag: Named entity tags identify proper names, such as person names, locations,
organizations, dates, and other named entities in a text. Example: In the sentence "John works at Apple Inc.
in California," the named entity tags could be "PERSON" for "John," "ORG" for "Apple Inc.," and
"LOCATION" for "California."
3. Sentiment Tag: Sentiment tags indicate the emotional polarity or sentiment expressed by a word
or phrase. They can be used to determine whether a text conveys a positive, negative, or neutral
sentiment. Example: In the sentence "I love this movie; it's fantastic," the sentiment tag for "love"
could be "POS" (positive) and for "fantastic" it could be "POS" as well.
4. Emotion Tag: Emotion tags capture the emotional content or sentiment associated with a word or
expression. They can represent emotions such as happiness, sadness, anger, surprise, etc.
Example: In the sentence "I'm so excited to see you!", the emotion tag for "excited" could be
"HAPPY."
5. Punctuation Tag: Punctuation tags represent various punctuation marks used in a text. They help
in identifying and distinguishing different types of punctuation, such as periods, commas,
question marks, exclamation marks, etc. Example: In the sentence "Where are you going?", the
punctuation tag for "?" could be "QUESTION_MARK."
Q2.
<book category="fantasy">
<title>Harry Potter and the Sorcerer's Stone</title>
<author>J.K. Rowling</author>
</book>
4. Text: Text refers to the actual content within an element. It can be plain text or data. For example,
in the following XML snippet, "Harry Potter and the Sorcerer's Stone" and "J.K. Rowling" are
the text content within the <title> and <author> elements, respectively:
<book>
<title>Harry Potter and the Sorcerer's Stone</title>
<author>J.K. Rowling</author>
</book>
5. Comments: Comments provide explanatory or informative notes within an XML document. They
are enclosed in <!-- -->
and and are not processed by XML parsers. Comments are useful for
adding human-readable descriptions or for temporarily disabling parts of the document.
<!-- This is a comment -->
<book>
<!-- This element represents a book -->
<title>Harry Potter and the Sorcerer's Stone</title>
<author>J.K. Rowling</author>
</book>
Q3.
With an element ID-based XPointer, you can reference an element by specifying its ID
value.
3. Range- based XPointer:
Range-based XPointer allows you to specify a range or selection of nodes within an XML
document.
It is used to address a portion of the document between two anchor points, such as start
and end tags or character positions.
Range-based XPointer is particularly useful for addressing specific sections of long
documents or fragments within elements.
4. Media-based XPointer:
Media-based XPointer is used to address specific parts within non-XML resources
embedded within an XML document, such as images, audio, video, etc.
It relies on media-specific addressing schemes to specify the desired location or fragment
within the media resource.
Media-based XPointer can be used to link to or reference specific portions of multimedia
content contained within an XML document.
b) Explain the concept of XSLT?
XSLT (Extensible Stylesheet Language Transformations) is a powerful language and technology used
for transforming XML documents into various formats, such as HTML, XML, plain text, or even
other XML structures. It is a key component of the broader XSL (Extensible Stylesheet Language)
family of standards.
Transformation process of XSLT –
1. XML Input Document:
XSLT begins with an XML input document that serves as the source of data to be
transformed.
The XML input document contains the data and structure that will be processed by the
XSLT transformation.
2. XSLT Stylesheet:
An XSLT stylesheet is created separately from the XML input document.
The stylesheet defines a set of rules, called templates, that dictate how the input document
should be transformed.
The stylesheet includes instructions on how to select elements or nodes, manipulate their
content, and generate the desired output.
3. Processing Model:
XSLT uses a processing model based on the concept of matching templates.
Templates are defined in the XSLT stylesheet and specify patterns for matching specific
elements or nodes in the XML input document.
When a template matches an element or node during the transformation, its associated
instructions are executed.
4. Template Execution:
During the transformation process, XSLT applies the templates defined in the stylesheet to
the XML input document.
Templates are executed in a recursive manner, starting from the root node and traversing
the XML document's hierarchy.
When a template matches an element or node, the instructions within that template are
executed to produce the desired output.
5. Output Generation:
As the templates are executed, XSLT generates the transformed output based on the
defined rules and instructions.
The output can be in various formats, such as HTML, XML, or plain text, depending on
the requirements specified in the XSLT stylesheet.
6. Transformation Result:
The final result of the XSLT transformation process is the transformed output document.
The output document reflects the structure and content defined by the XSLT stylesheet
and the rules applied during the transformation.
Set – II
Q4.
a) How does AJAX work? Explain with example.
AJAX, which stands for Asynchronous JavaScript and XML, is a technique used in web development
to create interactive and dynamic web pages. It allows web browsers to send and receive data from a
web server asynchronously without requiring the entire page to reload.
Working of AJAX is as follow –
1. Event Trigger: AJAX is typically triggered by an event on a web page, such as a button click or
a form submission.
2. JavaScript Request: When the event occurs, JavaScript code is executed to initiate an AJAX
request.
3. XMLHttpRequest Object: The XMLHttpRequest object is created by JavaScript to handle the
AJAX request. This object provides methods and properties to send and receive data from a server
without refreshing the entire page.
4. Data Sending: The XMLHttpRequest object sends a request to the server, including any data that
needs to be sent, such as form inputs or query parameters. This data is usually encoded in a format
like URL-encoded parameters or JSON.
5. Server Processing: The server receives the AJAX request, processes the data if necessary, and
generates a response.
6. Data Retrieval: The XMLHttpRequest object asynchronously retrieves the server's response
without reloading the entire page. This response can be in various formats, including HTML,
XML, JSON, or plain text.
7. Client-side Manipulation: Once the response is received, JavaScript code on the client-side can
manipulate the page's DOM (Document Object Model) to update the content dynamically. It can
add, remove, or modify elements on the page based on the data received.
8. Event Handling: If needed, event handlers can be attached to the newly added elements or
existing ones to provide additional interactivity.
b) What are different looping statements in PHP? Explain.
PHP provides several looping statements that allow us to execute a block of code repeatedly. The
main looping statements in PHP are:
1. for loop: The for loop is a common loop used when you know the number of iterations in
advance. It has three parts: initialization, condition, and increment/decrement. The loop continues
until the condition becomes false.
for ($i = 0; $i < 5; $i++) {
// code to be executed
}
2. while loop: The while loop executes a block of code as long as a specified condition is true. The
condition is checked before each iteration.
$i = 0;
while ($i < 5) {
// code to be executed
$i++;
}
3. do-while loop: The do-while loop is similar to the while loop, but it checks the condition after
each iteration. This guarantees that the block of code is executed at least once.
$i = 0;
do {
// code to be executed
$i++;
} while ($i < 5);
4. foreach loop: The foreach loop is used specifically for iterating over arrays or objects. It
automatically retrieves each element of an array or property of an object and assigns it to a
variable for further processing.
$fruits = array("apple", "banana", "orange");
foreach ($fruits as $fruit) {
// code to be executed for each element
echo $fruit;
}
Q5.
a) How can you load XML Data into an HTML Page? Explain with example.
To load XML data into an HTML page, you can use JavaScript along with the XMLHttpRequest
object or the fetch API. Here's a general approach using the XMLHttpRequest object:
1. Create an XMLHttpRequest Object:
var xmlhttp = new XMLHttpRequest();
2. Define a callback function to handle the XML data once it’s loaded:
xmlhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
// XML data is loaded, handle it here
var xmlData = this.responseXML;
// Process and display the XML data as desired
}
};
3. Open the XML file using the XMLHttpRequest Object:
xmlhttp.open("GET", "path/to/your/xmlfile.xml", true);
4. Set the response type to “document” to indicate that the response is an XML document:
xmlhttp.responseType = "document";
5. Send the XMLHttpRequest to initiate the request:
xmlhttp.send();
6. Inside the callback function, you can access the loaded XML data through the responseXML
property of the XMLHttpRequest object. You can then manipulate the XML data and extract the desired
information to display on the HTML page.
b) Define ASP session object with properties and methods.
In ASP (Active Server Pages), the Session object is a built-in object that allows you to store and
retrieve user-specific information across multiple pages during a user's session. It provides
properties and methods to manage session data. Here are some commonly used properties and
methods of the Session object:
Properties:
Q6.
a) How can we add parameters and return values in PHP functions?
In PHP, we can define functions that accept parameters and return values. Here's how you can add
parameters and return values in PHP functions:
1. Adding parameters:
We can define parameters in the function declaration to receive values from the calling code.
Parameters act as variables that hold the values passed to the function. You can then use these
values within the function's code. Syntax:
function functionName($param1, $param2, ...) {
// Function code that uses the parameters
}
2. Returning values: A function can return the value using the return statement. The returned value
can be of any data type, including strings, numbers, arrays, objects, etc. When a function
encounters the return statement, it immediately exits, and the specified value is returned to the
calling code.
Syntax:
b) How to establish MySQL connection and retrieve data using PHP Script? Explain with
example. Consider database named “UniversityDB” and table “Student”.
To establish a MySQL connection and retrieve data using a PHP script, you can utilize the MySQLi
extension, which provides an object-oriented approach for interacting with MySQL databases. Here's
an example that demonstrates how to establish a connection, retrieve data from the "Student" table in
the "UniversityDB" database, and display the results:
$host = "localhost";
$username = "your_username";
$password = "your_password";
$database = "UniversityDB";
if ($connection->connect_error) {
die("Connection failed: " . $connection->connect_error);
}
$result = $connection->query($query);
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
$studentId = $row["student_id"];
$firstName = $row["first_name"];
$lastName = $row["last_name"];
$connection->close();