Friday 1 January 2016

SMU ASSIGNMENT OF WEBSITE DISIGN BSC IT 3RD SEM

                                                         [FALL 2015]ASSIGNMENT
PROGRAM
BSc IT
SEMESTER
THIRD
SUBJECT CODE &
NAME
BT0078, Website Design

Q. No. 1. Explain the dial up connection and its types.
Answer: To access the Internet via a phone line, the concept is: Connect your computer to the telephone system using either a regular phone line (with a modem) or an ISDN line (which requires special equipment). To start work, you run a communication program to dial the phone and establish a connection with a remote Internet host. Once the connection is established, you log in to the server by typing your user name and password. At this point, there are three possible types of dial-up connections:
a) Shell account access
b) TCP/IP account access
c) Dial-up or on-demand TCP/IP link through your LAN
a) Conventional Dial-up Shell Account:With this type of account, you actually do your work on the remote computer. You establish an interactive session with another computer which is an Internet host. Your desktop assumes the role of an ASCII terminal. With shell access, your providers computer is considered a part of the Internet, but your computer is not. The only program that runs on your computer is the terminal emulator. When you connect to your provider, you type commands to its system, which tell it what functions you want to do. The program on your providers computer that receives and acts on the commands is known as a shell. The shell and the programs it runs for you send back to your computer some text that is displayed on the screen. A terminal emulator only supports a text-based interface, not a graphical interface. You are usually limited to running one client at a time
b) Protocol dial-up (TCP/IP Account): A protocol dialup account lets your computer behave like it is connected directly to another computer on the Internet, when it is really connected over a phone line whenever you dialup and it enables you to run software, such as a graphical Web browser like Microsoft Internet Explorer or Netscape Navigator, that functions in your computers native environment instead of forcing you to deal with plain text programs like the text only browser Lynx and UNIX. This means when you have a protocol dialup (TCP/IP) account, during the time you are connected your computer is a full-fledged Internet host. The client programs you use as many clients as you want at the same time. For example, you could start four programs, a web client, a gopher client, a mail client, and switch back and forth from one to the other. This type of connection is also known as TCP/IP type of account and it uses the TCP/IP protocol to perform data transfer on the Internet.
c) Dial-Up or On-Demand TCP/IP link through your LAN: A dial-up link from your LAN is the intermediate step between individual dial-up and a dedicated high speed link. It is therefore somewhat like dial-up and somewhat like having a direct link. The main difference between this type of connection and the one to your individual computer is that the TCP/IP software runs on the LAN server, and your connection is to the server. A TCP/IP connection through a LAN, either on a dial-up connection or a direct connection, is the most common type of IP connection, much more common than a personal dial-up IP connection.

Q. No. 2. Describe the following in context of validating XML documentswith DTDs
1. Concept of data validation
2. Writing document type definition (DTD) files
3. Internal and external DTDs
4. Validating parsers
5. The NMTOKEN and NMTOKENS Type
Answer: The Concept of Data Validation
The main requirement of the data validation is to determine whether all documents confirm to the rule it describes. Application programs that process the data in the collection of XML documents can be written to assume the particular document form. Without such structural restrictions, developing such applications would be difficult.
Writing Document Type Definition (DTD) Files
A Document Type Definition (DTD) is a set of structural rules called declarations, which specify a set of elements that can appear in the document as well as how and where these elements may appear. Not all XML documents need a DTD. DTDs are used when the same tag set definition is used by a collection of documents, perhaps by a collection of users, and the collection must have a consistent and uniform structure.
The purpose of a DTD is to define a standard form for a collection of XML documents. This form is specified as the tag and attributes sets, as well as rules that define how they can appear in a document. DTDs also provide entity definitions. All documents in the collection can be tested against the DTD to determine whether they conform to the rules it describes.
Internal and External DTDs
A DTD can be embedded in the XML document whose syntax rules it describes, in which case it is called an internal DTD. The alternative is to have the DTD stored in a separate file, in which case it is called an external DTD. Because external DTDs allow use with more than one XML document, they are preferable.
If the DTD is included in the XML code, it must be introduced with <!DOCTYPE rootname [ and terminated with ]>. For example, the structure of the planes XML document with its DTD included is as follows:
<?xml version = 1.0 encoding =utf-8 ?>
<!DOCTYPE planes [
<!-- the DTD for planes -->
]>
<!--The planes XML Document -->
When you use an external DTD, the XML document includes a DOCTYPE declaration as its second line. This declaration has the following form:
<!DOCTYPE XML_document_root_name SYSTEM DTD_file_name>
<!--The XML Document -->
Validating Parsers
All modern browsers have a built-in XML parser that can be used to read and manipulate XML. The parser reads XML into memory and converts it into an XML DOM object that can be accessed with JavaScript. There are some differences between Microsoft's XML parser and the parsers used in other browsers. The Microsoft parser supports loading of both XML files and XML strings (text), while other browsers use separate parsers. However, all parsers contain functions to traverse XML trees, access, insert, and delete nodes (elements) and their attributes.
The NMTOKEN and NMTOKENS Type
An XML name token is very close to an XML name. It must consist of the same characters as an XML name. Furthermore, like an XML name, an XML name token may not contain whitespace. However, a name token differs from an XML name in that any of the allowed characters can be the first character in a name token, while only letters, ideographs, and the underscore can be the first character of an XML name. Thus 12 and .cshrc are valid XML name tokens although they are not valid XML names. Every XML name is an XML name token, but not all XML name tokens are XML names.
Example:
<!ATTLIST journal year NMTOKEN #REQUIRED>
This still doesn't prevent the document author from assigning the year attribute values like "99" or "March", but it at least eliminates some possible wrong values, especially those that contain whitespace such as "1990 C.E." or "Sally had a little lamb."
A NMTOKENS type attribute contains one or more XML name tokens separated by whitespace. For example, you might use this to describe the date’s attribute of a performances element, if the dates were given in the form 08-26-2000, like this:
    <performances dates="08-21-2001 08-23-2001 08-27-2001">
Kat and the Kings
        </performances>
The appropriate declaration is:
              <!ATTLIST performances dates NMTOKENS #REQUIRED>
On the other hand, you could not use this for a list of dates in the form 08/27/2001 because the forward slash is not a legal name character.

Q. No. 3. Explain the following:
1. Declaring XSL style sheets
2. xsl:apply-templates
3. XPath Functions and Predicates
4. Looping - xsl:for-each
Answer: Declaring XSL Stylesheets
XSL documents must conform to the rules of any other XML document, in that the syntax of the document must be well-formed, such as the proper nesting of tags, no empty tags, etc. The stylesheet can contain text that will be reflected exactly in the output document, in addition to XSL instructions that copy the data from the XML document the stylesheet is being applied to. The declaration of the stylesheet, with the processing instructions to the browser is done as follows.
< xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
What this line is doing is declaring the element an xsl:stylesheet element and calling for the XSL elements that are in the http://www.w3.org/TR/WD-xsl namespace. Of course, for the document to be well formed, this tag must be closed at the very end of the document with the close tag:
</xsl:stylesheet>
xsl:apply-templates
The xsl:apply-templatesselects source nodes for processing. The format is given below:
<xsl:apply-templates [select="pattern"][mode="qname"]>
[<xsl:sort>]
</xsl:apply-templates>
If you specify the select attribute, specify a pattern that resolves to a set of source nodes. For each source node in this set, the XSLT processor searches for a template that matches the node. When it finds a matching template, it instantiates it and uses the node as the context node. For example:
<xsl:apply-templates select="/bookstore/book">
When the XSLT processor executes this instruction, it constructs a list of all nodes that match the pattern in the select attribute. For each node in the list, the XSLT processor searches for the template whose match pattern best matches that node. If you do not specify the select attribute, the XSLT processor uses the default pattern, "node()", which selects all child nodes of the current node.
If you specify the mode attribute, the selected nodes are matched only by templates with a matching mode attribute. The value of mode must be a qualified name or an asterisk (*). If you specify an asterisk, it means continue the current mode, if any, of the current template. If you do not specify a mode attribute, the selected nodes are matched only by templates that do not specify a mode attribute.
By default, the new list of source nodes is processed in document order. However, you can use the xsl:sort instruction to specify that the selected nodes are to be processed in a different order.
In the previous example, the XSLT processor searches for a template that matches /bookstore/book. The following template is a match:
<xsl:template match="book">
<tr><td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="author"/><td>
<td><xsl:value-of select="price"/><td></tr>
</xsl:template>
The XSLT processor instantiates this template for each book element.
XPath Functions and Predicates
You can use XML Path Language (Xpath) functions to refine XPath queries and enhance the programming power and flexibility of XPath. The functions are divided into the following groups.



Table: Six Functions
Node-Set
Takes a node-set argument, returns a node-set, or returns/provides information about a particular node within a node-set.
String
Performs evaluations, formatting, and manipulation on string arguments.
Boolean
Evaluates the argument expressions to obtain a Boolean result.
Number
Evaluates the argument expressions to obtain a numeric result.
Microsoft XPath Extension Functions
Microsoft extension functions to XPath that provide the ability to select nodes by XSD type. Also includes string comparison, number comparison, and date/time conversion functions.

Each function in the function library is specified using a function prototype that provides the return type, function name, and argument type. If an argument type is followed by a question mark, the argument is optional; otherwise, the argument is required. Function names are case-sensitive.
A predicate is similar to an If/Then statement. If our predicate is TRUE, then the element will be selected. If the predicate is FALSE, it will be excluded. An XPath predicate is contained within square brackets [], and comes after the parent element of what will be tested.
Example: inventory/drink/lemonade[amount>15]
Besides testing the values of elements, you can also use predicates to check the values of attributes. The form pretty much the same as before, except the attribute belongs to the element before the predicate.
Syntax: element[@element'sAttribute someTestHere]
Looping - xsl:for-each
The <xsl:for-each> element allows you to do looping in XSLT. The XSL <xsl:for-each> element can be used to select every XML element of a specified node-set:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Title</th>
<th>Artist</th>
</tr>
<xsl:for-each select="catalog/cd">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
The result of the transformation above will look like this:
Title
Artist
Empire Burlesque
Bob Dylan
Hide your heart
Bonnie Tyler
Greatest Hits
Dolly Parton
Still got the blues
Gary More
Eros
Eros Ramazzotti
One night only
Bee Gees




1 comment:

  1. You did really good work. I appreciate your new and different post. Please guys keep it up
    I have also written a good Profile Why Spacebar Speed. Read the Profile and comment on your view.

    ReplyDelete