Professional Documents
Culture Documents
IP (Internet Protocol):
IP is the protocol that controls how data moves around on the network. After TCP
divides the message into segment, IP labels them with source and destination. These
packets are now called IP datagrams. IP is the primary protocol in the Internet Layer
of the Internet protocol suite and has the task of delivering datagrams from the source
host to the destination host solely based on their addresses. IP also takes care of
sending the datagrams by determining the route. These datagrams may hop several
networks before reaching the destination. Below diagram 1.3 shows TCP/IP
Communications.
1
SIKKIM MANIPAL UNIVERSITY, DE
In the above diagram 1.3, at the destination the IP verifies the labels and passes them
to the TCP. The TCP checks if all the segments have been received. If any of the
segments are missing it informs this to the source TCP and requests the segment to
be sent again. It is called retry. After verification, the TCP assembles the message
from these data segments and supplies to the destination program.
UDP (User Datagram Protocol) UDP is connection-less transport layer protocol. The
UDP port identifies various applications running on a device. UDP adds no reliability,
flow control or error recovery. Each datagram is independent of others, and they may
be lost by the networks or arrive out of order. A receiving system remains unaware of
the sending of a datagram unless it arrives. UDP is used in situations where reliability
is not required and it is helpful in multimedia and multicasting applications.
2
SIKKIM MANIPAL UNIVERSITY, DE
Q2 Describe the features of XML. What are the important rules to keep in mind
about the XML declaration
There are few other important rules to keep in mind about the XML declaration:
a) The XML declaration is case sensitive: it may not begin with <?XML or any other
variant.
b) If the XML declaration appears at all, it must be the very first thing in the XML
document: not even whitespace or comments may appear before it; and
c) It is legal for a transfer protocol like HTTP to override the encoding value that you
put in the XML declaration, so you cannot guarantee that the document will actually
use the encoding provided in the XML declaration.
d) Elements may not overlap: an end tag must always have the same name as the
most recent unmatched start tag. The following example is well-formed XML
document.
3
SIKKIM MANIPAL UNIVERSITY, DE
e) An XML document has exactly one root element. As a result, the following example
is not a well-formed XML document, because both the university and books elements
occur at the top level:
<! -- WRONG! -->
<University>...</university>
<Books>...</Books>
The following example fixes the problem by including both the University and Books
elements within a new Education root element:
<Education>
<University>...</University>
<Books>...</Books>
</education>
If we use the structure of Sikkim Manipal University as a model for understanding the
structure of an XML document, we can easily understand the flow of our information in
our document. Figure 4.1 shows a tree structure of an XML document is similar to the
structure of Sikkim Manipal University.
4
SIKKIM MANIPAL UNIVERSITY, DE
In the following figure 7.1 we have conversed about XML parsing process operates in
three phases:
Stage 1: In this stage, the application parses and validates the source document;
recognizes and searches for relevant information based on its location or its tagging in
the source document; extracts the relevant information when it is located; and,
optionally, maps and binds the retrieved information to business objects.
Stage 2: Business logic handling. This is the stage in which the actual processing of
the input information takes place. It might result in the generation of output
information.
Stage 3: XML output processing. In this stage, the application constructs a model of
the document to be generated with the Document Object Model (DOM). It then either
applies XSLT style sheets or directly serializes to XML.
b) Event switcher The event switcher receives a stream of tokens from the parser and
sorts them according to function, like a switchboard telephone operator of old. Some
tokens signal that a change in behaviour is necessary. These are called events. One
event may be that a processing instruction with a target keyword significant to the
XML processor has been found. Another may be that a <title> element has been seen,
signalling the need for a font change. What the events are and how they are handled
are up to the particular processor. On receiving an event, it routes processing to a
subroutine, which is called an event handler or sometimes a call-back procedure. This
is often all that the XML processor needs to do, but sometimes more complex
processing is required, such as building and operating on an internal tree model.
5
SIKKIM MANIPAL UNIVERSITY, DE
c) Tree representation The tree representation can take many forms, but there are two
main types.
i) The first is a simple structure consisting of a hierarchy of node lists. This is the kind
of structure you would find in a non-object- oriented approach.
ii) The other kind is called an object model, where every node is represented as an
object. In a programming phrase, an object is a package of data and routines in a
rigid, cloudy framework. This style is preferred for large programs, because it
minimizes certain types of bugs and is usually easier to visualize. Object trees are
expensive in terms of speed and memory, but for many applications this is an
acceptable trade-off for convenience of development.
d) Tree processor The tree processor is the part of the program that operates on the
tree model. It can be anything from a validity checker to a full-blown transformation
engine. It traverses the tree, usually in a methodical, depth- first order in which it goes
to the end of a branch and backtracks to find the last unchecked node. Often, its
actions are controlled by a list of rules, where a rule is some description of how to
handle a piece of the tree. For example, the tree processor may use the rules from a
stylesheet to translate XML markup into formatted text.
Q4. Describe the procedure of fetching data from XML to HTML give an example.
Ans: Loading XML Data into an HTML Page The process of fetching data from an
XML files to be filled in an HTML table, using DSO (Data Source Object) and
JavaScript. DSO is an object that operates like a database on the client side. It will
accept information that is organized in a certain way and will manipulate it with its own
database engine.
DSO allows data binding to HTML table elements. When a table element is bound
there is no need to write out the code for individual rows for each record in the
recordset. The DSO will automatically do this for each record.
To bind the XML data to an HTML table, add a datasrc attribute to the table element,
and add the datafld attribute to the span elements inside the table data.
For example
<table width="80%" id=nbbeq datasrc="#equipdet" border="1">
<caption>
<span class="style1">example</span>
</caption>
<thead>
<tr> ...... </tr>
</thead> <tbody>
<tr> .... </tr>
</tbody>
</table>
6
SIKKIM MANIPAL UNIVERSITY, DE
Example using scripting: Using JavaScript to load the XML file data to the HTML file
using DSO
First we create a new DSO via code:
<object id="nb_equip" CLASSID="clsid:550dda30-0541-11d2-9ca9- 0060b0ec3d39"
width="0" height="0">
</object>
Next we make a DOM object. This is done using the XMLDocument property of the
DSO.
var doc=nb_equip.XMLDocument;
Once a DOM object has been created use the load method of the DOM object to load
a file:
doc.load("equip.xml");
The following JavaScript function is used to load the XML file to DSO objects. When
the user calls this function it will load the XML file and bind the data to the HTML table
based on datasrc and datafld attributes:
<html>
<body>
<script type="text/javascript">
if (window.XMLHttpRequest)
{
xmlhttp=new XMLHttpRequest();
}
else
{
Xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","cd_catalog.xml",false);
xmlhttp.send();
xmlDoc = xmlhttp.responseXML;
document.write("<table border='1'>");
var x = xmlDoc.getElementsByTagName("CD");
for (i=0;i<x.length;i++)
{
document.write("<tr><td>");
document.write(x[i].getElementsByTagName("ARTIST")[0].childNodes[0].no
deValue); document.write("</td><td>");
document.write(x[i].getElementsByTagName("TITLE")[0].childNodes[0].
nodeValue); document.write("</td></tr>");
} document.write("</table>");
</script>
</body>
</html>
7
SIKKIM MANIPAL UNIVERSITY, DE
Assignment Operators
Arithmetic Operators
Comparison Operators
String Operators
The Concatenation Operator
Assignment operators are used to set a variable equal to a value or set a variable to
another variable's value. Such an assignment of value is done with the "=", or equal
character. Example:
$my_data = 2;
$another_data = $my_data Now both $my_data and $another_data contain the
value 2.
Assignments can also be used in conjunction with arithmetic operators.
Arithmetic operators are used to perform mathematical operations like addition,
subtraction, multiplication, division and Modulus. Table 11.1 shows all the arithmetic
operators.
Table
8
SIKKIM MANIPAL UNIVERSITY, DE
The Concatenation Operator There is only one string operator in PHP. The
concatenation operator (.) is used to put two string values together. To concatenate
two string variables together, use the concatenation operator: <?php $txt1="Hello
World!"; $txt2="Distance education!"; echo $txt1 . " " . $txt2; ?>
The output of the code above will be: Hello World! Distance education!
9
SIKKIM MANIPAL UNIVERSITY, DE
Ans: Introduction of ASP Active Server Pages (ASPs) are Web pages that contain
server-side scripts in addition to the usual mixture of text and HTML (Hypertext
Markup Language) tags. Server-side scripts are special code that is put in Web Pages
and that code is processed before it is sent to the Web browser of someone who's
visiting your Web site. When we type a URL in the Addressbox or click a link on a
Web page it means we are asking a Web server to send a file to the Web browser on
our computer. If that file is a normal HTML file, it looks exactly the same when your
Web browser receives it as it did before the Web server sent it. After receiving the file,
your Web browser displays its contents as a combination of text, images, and sounds.
In the case of an Active Server Page, the process is similar, except there's an extra
processing step that takes place just before the Web server sends the file. Before the
Web server sends the Active Server Page to the Web browser, it runs all server-side
scripts contained in the page.
To distinguish them from normal HTML pages, Active Server Pages are given the
".asp" extension. The basic difference between HTML and ASP is that ASP is used to
design user-interactive pages or dynamic pages with database access whereas HTML
is used to design static Pages.
How ASP Works? Following are some steps that will help us to know about ASP
working:
1. The user brings up a Web site where the default page has the extension .asp.
2. The browser requests the ASP file from the Web server.
3. The server-side script begins to run with ASP.
4. ASP processes the requested file sequentially (top-down), executes any script
commands contained in the file, and produces an HTML Web page.
5. The Web page is sent to the browser.
Because our script runs on the server, the Web server does all of the processing and
standard HTML pages can be generated and sent to the browser. This means that our
Web pages are limited only by what our Web server supports. Another benefit of
having our script reside on the server is that the user cannot "view source" on the
original script and code. Instead, the user sees only the generated HTML as well as
non-HTML content, such as XML, on the pages that are being viewed. Following
figure 13.1 shows the working of ASP page
10
SIKKIM MANIPAL UNIVERSITY, DE
Server-side scripts look a lot like HTML tags. However, instead of starting and ending
with lesser-than ( < ) and greater-than ( > ) brackets, they typically start with <% and
end with %>. The <% is called an opening tag, and the %> is called a closing tag. In
between these tags are the server- side scripts. You can insert server-side scripts
anywhere in your Web page-- even inside HTML tags
11
SIKKIM MANIPAL UNIVERSITY, DE
12
SIKKIM MANIPAL UNIVERSITY, DE
13