WE Expriment Manual1

  • Upload
    akkik

  • View
    224

  • Download
    0

Embed Size (px)

Citation preview

  • 8/14/2019 WE Expriment Manual1

    1/40

    Expriment No.1

    Aim: To Study of all HTML tags.

    Problem Statement: WAP to design resume using basic HTML Tags.WAP to design student information form using HTML form tag.

    WAP using frame tag.

    Requirement: Notepad, Internet Explorer

    Theory:

    HTML is an abbreviation of "HyperText Mark-up Language" - which is

    already more than you need to know at this stage. However, for the sake of good order,let us explain in greater detail.

    Hyper is the opposite of linear. In the good old days - when a mouse wassomething the cat chased - computer programs ran linearly: when the program had

    executed one action it went to the next line and after that, the next line and so on.But HTML is different - you can go wherever you want and whenever you want.

    For example, it is not necessary to visit MSN.com before you visit HTML.net.

    Text is self-explanatory.

    Mark-up is what you do with the text. You are marking up the text the same way

    you do in a text editing program with headings, bullets and bold text and so on.

    Language is what HTML is. It uses many English words.

    HTML Tags

    HTML markup tags are usually called HTML tags

    HTML tags are keywords surrounded by angle brackets like

    HTML tags normally come in pairs like and

    The first tag in a pair is the start tag, the second tag is the end tag

    Start and end tags are also called opening tags and closing tags.

    Tag Description

    Defines a comment Defines the document type

    Defines an anchor

    Defines an abbreviation

    Defines an acronym

    Defines contact information for the author/owner of a document

    Deprecated. Defines an embedded applet

    http://www.w3schools.com/tags/tag_comment.asphttp://www.w3schools.com/tags/tag_doctype.asphttp://www.w3schools.com/tags/tag_a.asphttp://www.w3schools.com/tags/tag_abbr.asphttp://www.w3schools.com/tags/tag_acronym.asphttp://www.w3schools.com/tags/tag_address.asphttp://www.w3schools.com/tags/tag_applet.asphttp://www.w3schools.com/tags/tag_comment.asphttp://www.w3schools.com/tags/tag_doctype.asphttp://www.w3schools.com/tags/tag_a.asphttp://www.w3schools.com/tags/tag_abbr.asphttp://www.w3schools.com/tags/tag_acronym.asphttp://www.w3schools.com/tags/tag_address.asphttp://www.w3schools.com/tags/tag_applet.asp
  • 8/14/2019 WE Expriment Manual1

    2/40

    Defines an area inside an image-map

    Defines bold text

    Defines a default address or a default target for all links on a page

    Deprecated. Defines a default font, color, or size for the text in a page

    Defines the text direction

    Defines big text

    Defines a long quotation

    Defines the document's body


    Defines a single line break

    Defines a push button

    Defines a table caption

    Deprecated. Defines centered text

    Defines a citation

    Defines computer code text

    Defines attribute values for one or more columns in a table Defines a group of columns in a table for formatting

    Defines a description of a term in a definition list

    Defines deleted text

    Deprecated. Defines a directory list

    Defines a section in a document

    Defines a definition term

    Defines a definition list

    Defines a term (an item) in a definition list

    Defines emphasized text

    Defines a border around elements in a form

    Deprecated. Defines font, color, and size for text

    Defines an HTML form for user input

    Defines a window (a frame) in a frameset

    Defines a set of frames

    to Defines HTML headings

    Defines information about the document

    Defines a horizontal line

    Defines an HTML document

    Defines italic text

    Defines an inline frame

    Defines an image

    Defines an input control

    Defines inserted text

    Deprecated. Defines a searchable index related to a document

    Defines keyboard text

    http://www.w3schools.com/tags/tag_area.asphttp://www.w3schools.com/tags/tag_font_style.asphttp://www.w3schools.com/tags/tag_base.asphttp://www.w3schools.com/tags/tag_basefont.asphttp://www.w3schools.com/tags/tag_bdo.asphttp://www.w3schools.com/tags/tag_font_style.asphttp://www.w3schools.com/tags/tag_blockquote.asphttp://www.w3schools.com/tags/tag_body.asphttp://www.w3schools.com/tags/tag_br.asphttp://www.w3schools.com/tags/tag_button.asphttp://www.w3schools.com/tags/tag_caption.asphttp://www.w3schools.com/tags/tag_center.asphttp://www.w3schools.com/tags/tag_phrase_elements.asphttp://www.w3schools.com/tags/tag_phrase_elements.asphttp://www.w3schools.com/tags/tag_col.asphttp://www.w3schools.com/tags/tag_colgroup.asphttp://www.w3schools.com/tags/tag_dd.asphttp://www.w3schools.com/tags/tag_del.asphttp://www.w3schools.com/tags/tag_dir.asphttp://www.w3schools.com/tags/tag_div.asphttp://www.w3schools.com/tags/tag_phrase_elements.asphttp://www.w3schools.com/tags/tag_dl.asphttp://www.w3schools.com/tags/tag_dt.asphttp://www.w3schools.com/tags/tag_phrase_elements.asphttp://www.w3schools.com/tags/tag_fieldset.asphttp://www.w3schools.com/tags/tag_font.asphttp://www.w3schools.com/tags/tag_form.asphttp://www.w3schools.com/tags/tag_frame.asphttp://www.w3schools.com/tags/tag_frameset.asphttp://www.w3schools.com/tags/tag_hn.asphttp://www.w3schools.com/tags/tag_head.asphttp://www.w3schools.com/tags/tag_hr.asphttp://www.w3schools.com/tags/tag_html.asphttp://www.w3schools.com/tags/tag_font_style.asphttp://www.w3schools.com/tags/tag_iframe.asphttp://www.w3schools.com/tags/tag_img.asphttp://www.w3schools.com/tags/tag_input.asphttp://www.w3schools.com/tags/tag_ins.asphttp://www.w3schools.com/tags/tag_phrase_elements.asphttp://www.w3schools.com/tags/tag_area.asphttp://www.w3schools.com/tags/tag_font_style.asphttp://www.w3schools.com/tags/tag_base.asphttp://www.w3schools.com/tags/tag_basefont.asphttp://www.w3schools.com/tags/tag_bdo.asphttp://www.w3schools.com/tags/tag_font_style.asphttp://www.w3schools.com/tags/tag_blockquote.asphttp://www.w3schools.com/tags/tag_body.asphttp://www.w3schools.com/tags/tag_br.asphttp://www.w3schools.com/tags/tag_button.asphttp://www.w3schools.com/tags/tag_caption.asphttp://www.w3schools.com/tags/tag_center.asphttp://www.w3schools.com/tags/tag_phrase_elements.asphttp://www.w3schools.com/tags/tag_phrase_elements.asphttp://www.w3schools.com/tags/tag_col.asphttp://www.w3schools.com/tags/tag_colgroup.asphttp://www.w3schools.com/tags/tag_dd.asphttp://www.w3schools.com/tags/tag_del.asphttp://www.w3schools.com/tags/tag_dir.asphttp://www.w3schools.com/tags/tag_div.asphttp://www.w3schools.com/tags/tag_phrase_elements.asphttp://www.w3schools.com/tags/tag_dl.asphttp://www.w3schools.com/tags/tag_dt.asphttp://www.w3schools.com/tags/tag_phrase_elements.asphttp://www.w3schools.com/tags/tag_fieldset.asphttp://www.w3schools.com/tags/tag_font.asphttp://www.w3schools.com/tags/tag_form.asphttp://www.w3schools.com/tags/tag_frame.asphttp://www.w3schools.com/tags/tag_frameset.asphttp://www.w3schools.com/tags/tag_hn.asphttp://www.w3schools.com/tags/tag_head.asphttp://www.w3schools.com/tags/tag_hr.asphttp://www.w3schools.com/tags/tag_html.asphttp://www.w3schools.com/tags/tag_font_style.asphttp://www.w3schools.com/tags/tag_iframe.asphttp://www.w3schools.com/tags/tag_img.asphttp://www.w3schools.com/tags/tag_input.asphttp://www.w3schools.com/tags/tag_ins.asphttp://www.w3schools.com/tags/tag_phrase_elements.asp
  • 8/14/2019 WE Expriment Manual1

    3/40

    Defines a label for an input element

    Defines a caption for a fieldset element

    Defines a list item

    Defines the relationship between a document and an external resource

    Defines an image-map

    Deprecated. Defines a menu list

    Defines metadata about an HTML document

    Defines an alternate content for users that do not support frames

    Defines an alternate content for users that do not support client-side scripts

    Defines an embedded object

    Defines an ordered list

    Defines a group of related options in a select list

    Defines an option in a select list

    Defines a paragraph

    Defines a parameter for an object Defines preformatted text

    Defines a short quotation

    Deprecated. Defines strikethrough text

    Defines sample computer code

    Defines a client-side script

    Defines a select list (drop-down list)

    Defines small text

    Defines a section in a document

    Deprecated. Defines strikethrough text

    Defines strong text

    Defines style information for a document

    Defines subscripted text

    Defines superscripted text

    Defines a table

    Groups the body content in a table

    Defines a cell in a table

    Defines a multi-line text input control

    Groups the footer content in a table

    Defines a header cell in a table

    Groups the header content in a table

    Defines the title of a document

    Defines a row in a table

    Defines teletype text

    Deprecated. Defines underlined text

    Defines an unordered list

    http://www.w3schools.com/tags/tag_label.asphttp://www.w3schools.com/tags/tag_legend.asphttp://www.w3schools.com/tags/tag_li.asphttp://www.w3schools.com/tags/tag_link.asphttp://www.w3schools.com/tags/tag_map.asphttp://www.w3schools.com/tags/tag_menu.asphttp://www.w3schools.com/tags/tag_meta.asphttp://www.w3schools.com/tags/tag_noframes.asphttp://www.w3schools.com/tags/tag_noscript.asphttp://www.w3schools.com/tags/tag_object.asphttp://www.w3schools.com/tags/tag_ol.asphttp://www.w3schools.com/tags/tag_optgroup.asphttp://www.w3schools.com/tags/tag_option.asphttp://www.w3schools.com/tags/tag_p.asphttp://www.w3schools.com/tags/tag_param.asphttp://www.w3schools.com/tags/tag_pre.asphttp://www.w3schools.com/tags/tag_q.asphttp://www.w3schools.com/tags/tag_strike.asphttp://www.w3schools.com/tags/tag_phrase_elements.asphttp://www.w3schools.com/tags/tag_script.asphttp://www.w3schools.com/tags/tag_select.asphttp://www.w3schools.com/tags/tag_font_style.asphttp://www.w3schools.com/tags/tag_span.asphttp://www.w3schools.com/tags/tag_strike.asphttp://www.w3schools.com/tags/tag_phrase_elements.asphttp://www.w3schools.com/tags/tag_style.asphttp://www.w3schools.com/tags/tag_sup.asphttp://www.w3schools.com/tags/tag_sup.asphttp://www.w3schools.com/tags/tag_table.asphttp://www.w3schools.com/tags/tag_tbody.asphttp://www.w3schools.com/tags/tag_td.asphttp://www.w3schools.com/tags/tag_textarea.asphttp://www.w3schools.com/tags/tag_tfoot.asphttp://www.w3schools.com/tags/tag_th.asphttp://www.w3schools.com/tags/tag_thead.asphttp://www.w3schools.com/tags/tag_title.asphttp://www.w3schools.com/tags/tag_tr.asphttp://www.w3schools.com/tags/tag_font_style.asphttp://www.w3schools.com/tags/tag_u.asphttp://www.w3schools.com/tags/tag_ul.asphttp://www.w3schools.com/tags/tag_label.asphttp://www.w3schools.com/tags/tag_legend.asphttp://www.w3schools.com/tags/tag_li.asphttp://www.w3schools.com/tags/tag_link.asphttp://www.w3schools.com/tags/tag_map.asphttp://www.w3schools.com/tags/tag_menu.asphttp://www.w3schools.com/tags/tag_meta.asphttp://www.w3schools.com/tags/tag_noframes.asphttp://www.w3schools.com/tags/tag_noscript.asphttp://www.w3schools.com/tags/tag_object.asphttp://www.w3schools.com/tags/tag_ol.asphttp://www.w3schools.com/tags/tag_optgroup.asphttp://www.w3schools.com/tags/tag_option.asphttp://www.w3schools.com/tags/tag_p.asphttp://www.w3schools.com/tags/tag_param.asphttp://www.w3schools.com/tags/tag_pre.asphttp://www.w3schools.com/tags/tag_q.asphttp://www.w3schools.com/tags/tag_strike.asphttp://www.w3schools.com/tags/tag_phrase_elements.asphttp://www.w3schools.com/tags/tag_script.asphttp://www.w3schools.com/tags/tag_select.asphttp://www.w3schools.com/tags/tag_font_style.asphttp://www.w3schools.com/tags/tag_span.asphttp://www.w3schools.com/tags/tag_strike.asphttp://www.w3schools.com/tags/tag_phrase_elements.asphttp://www.w3schools.com/tags/tag_style.asphttp://www.w3schools.com/tags/tag_sup.asphttp://www.w3schools.com/tags/tag_sup.asphttp://www.w3schools.com/tags/tag_table.asphttp://www.w3schools.com/tags/tag_tbody.asphttp://www.w3schools.com/tags/tag_td.asphttp://www.w3schools.com/tags/tag_textarea.asphttp://www.w3schools.com/tags/tag_tfoot.asphttp://www.w3schools.com/tags/tag_th.asphttp://www.w3schools.com/tags/tag_thead.asphttp://www.w3schools.com/tags/tag_title.asphttp://www.w3schools.com/tags/tag_tr.asphttp://www.w3schools.com/tags/tag_font_style.asphttp://www.w3schools.com/tags/tag_u.asphttp://www.w3schools.com/tags/tag_ul.asp
  • 8/14/2019 WE Expriment Manual1

    4/40

    Defines a variable part of a text

    Deprecated. Defines preformatted tex

    Output:

    Conclusion: Thus we studied all basic html tags.

    http://www.w3schools.com/tags/tag_phrase_elements.asphttp://www.w3schools.com/tags/tag_phrase_elements.asp
  • 8/14/2019 WE Expriment Manual1

    5/40

    Expriment No.2

    Aim: To Study of java scripts.

    Problem Statement: WAP to design resume using basic HTML Tags.

    WAP to design student information form using HTML form tag.WAP using frame tag.

    Requirement: Notepad, Internet Explorer

    Theory:

    What is JavaScript?

    JavaScript was designed to add interactivity to HTML pages

    JavaScript is a scripting language A scripting language is a lightweight programming language

    JavaScript is usually embedded directly into HTML pages

    JavaScript is an interpreted language (means that scripts execute withoutpreliminary compilation)

    Everyone can use JavaScript without purchasing a license

    JavaScript Statements

    A JavaScript statement is a command to a browser. The purpose of the command is to tellthe browser what to do.

    This JavaScript statement tells the browser to write "Hello Dolly" to the web page:

    document.write("Hello Dolly");

    It is normal to add a semicolon at the end of each executable

    statement. Most people think this is a good programming practice, andmost often you will see this in JavaScript examples on the web.

    JavaScript Variables

    As with algebra, JavaScript variables are used to hold values or expressions.

    A variable can have a short name, like x, or a more descriptive name, like carname.

    Rules for JavaScript variable names:

    Variable names are case sensitive (y and Y are two different variables)

  • 8/14/2019 WE Expriment Manual1

    6/40

    Variable names must begin with a letter or the underscore character

    Operators:

    JavaScript Arithmetic Operators

    Arithmetic operators are used to perform arithmetic between variables and/or values.

    Given that y=5, the table below explains the arithmetic operators:

    Operator Description Example Result

    + Addition x=y+2 x=7

    - Subtraction x=y-2 x=3

    * Multiplication x=y*2 x=10

    / Division x=y/2 x=2.5

    % Modulus (division remainder) x=y%2 x=1

    ++ Increment x=++y x=6

    -- Decrement x=--y x=4

    JavaScript Assignment Operators

    Assignment operators are used to assign values to JavaScript variables.

    Given that x=10 and y=5, the table below explains the assignment operators:

    Operator Example Same As Result

    = x=y x=5

    += x+=y x=x+y x=15

    -= x-=y x=x-y x=5

    *= x*=y x=x*y x=50

    /= x/=y x=x/y x=2

    %= x%=y x=x%y x=0

  • 8/14/2019 WE Expriment Manual1

    7/40

    Comparison Operators

    Comparison operators are used in logical statements to determine equality or difference

    between variables or values.

    Given that x=5, the table below explains the comparison operators:

    Operator Description Example

    == is equal to x==8 is false

    === is exactly equal to (value and type) x===5 is true

    x==="5" is false

    != is not equal x!=8 is true

    > is greater than x>8 is false

    < is less than x= is greater than or equal to x>=8 is false

  • 8/14/2019 WE Expriment Manual1

    8/40

    Conditional Statements

    Very often when you write code, you want to perform different actions for different

    decisions. You can use conditional statements in your code to do this.

    In JavaScript we have the following conditional statements:

    if statement - use this statement to execute some code only if a specifiedcondition is true

    if...else statement - use this statement to execute some code if the condition is

    true and another code if the condition is false

    if...else if....else statement - use this statement to select one of many blocks of

    code to be executed

    switch statement - use this statement to select one of many blocks of code to beexecuted

    JavaScript Loops

    Often when you write code, you want the same block of code to run over and over again

    in a row. Instead of adding several almost equal lines in a script we can use loops to

    perform a task like this.

    In JavaScript, there are two different kind of loops:

    for - loops through a block of code a specified number of times

    while - loops through a block of code while a specified condition is true

    The Array Object

    The Array object is used to store multiple values in a single variable.

    Syntax for creating an Array object:

    var myCars=new Array("Saab","Volvo","BMW")

    To access and to set values inside an array, you must use the index numbers as follows:

    myCars[0] is the first element

    myCars[1] is the second element myCars[2] is the third element

    Array Object Properties

    FF: Firefox, IE: Internet Explorer

  • 8/14/2019 WE Expriment Manual1

    9/40

    Property Description FF IE

    constructor Returns a reference to the array function that created the object 1 4

    index 1 4

    input 1 4

    length Sets or returns the number of elements in an array 1 4

    prototype Allows you to add properties and methods to the object 1 4

    Array Object Methods

    Method Description FF IE

    concat() Joins two or more arrays and returns the result 1 4

    join() Puts all the elements of an array into a string. The elements are

    separated by a specified delimiter

    1 4

    pop() Removes and returns the last element of an array 1 5.5push() Adds one or more elements to the end of an array and returns the

    new length

    1 5.5

    reverse() Reverses the order of the elements in an array 1 4

    shift() Removes and returns the first element of an array 1 5.5

    slice() Returns selected elements from an existing array 1 4

    sort() Sorts the elements of an array 1 4

    splice() Removes and adds new elements to an array 1 5.5

    toSource() Represents the source code of an object 1 -toString() Converts an array to a string and returns the result 1 4

    unshift() Adds one or more elements to the beginning of an array andreturns the new length

    1 6

    valueOf() Returns the primitive value of an Array object 1 4

    Conclusion: Thus we studied all basic html tags.

    http://www.w3schools.com/jsref/jsref_constructor_array.asphttp://www.w3schools.com/jsref/jsref_length_array.asphttp://www.w3schools.com/jsref/jsref_prototype_array.asphttp://www.w3schools.com/jsref/jsref_concat_array.asphttp://www.w3schools.com/jsref/jsref_join.asphttp://www.w3schools.com/jsref/jsref_pop.asphttp://www.w3schools.com/jsref/jsref_push.asphttp://www.w3schools.com/jsref/jsref_reverse.asphttp://www.w3schools.com/jsref/jsref_shift.asphttp://www.w3schools.com/jsref/jsref_slice_array.asphttp://www.w3schools.com/jsref/jsref_sort.asphttp://www.w3schools.com/jsref/jsref_splice.asphttp://www.w3schools.com/jsref/jsref_toSource_array.asphttp://www.w3schools.com/jsref/jsref_toString_array.asphttp://www.w3schools.com/jsref/jsref_unshift.asphttp://www.w3schools.com/jsref/jsref_valueOf_array.asphttp://www.w3schools.com/jsref/jsref_constructor_array.asphttp://www.w3schools.com/jsref/jsref_length_array.asphttp://www.w3schools.com/jsref/jsref_prototype_array.asphttp://www.w3schools.com/jsref/jsref_concat_array.asphttp://www.w3schools.com/jsref/jsref_join.asphttp://www.w3schools.com/jsref/jsref_pop.asphttp://www.w3schools.com/jsref/jsref_push.asphttp://www.w3schools.com/jsref/jsref_reverse.asphttp://www.w3schools.com/jsref/jsref_shift.asphttp://www.w3schools.com/jsref/jsref_slice_array.asphttp://www.w3schools.com/jsref/jsref_sort.asphttp://www.w3schools.com/jsref/jsref_splice.asphttp://www.w3schools.com/jsref/jsref_toSource_array.asphttp://www.w3schools.com/jsref/jsref_toString_array.asphttp://www.w3schools.com/jsref/jsref_unshift.asphttp://www.w3schools.com/jsref/jsref_valueOf_array.asp
  • 8/14/2019 WE Expriment Manual1

    10/40

    Expriment No.3

    Aim: To Study of servlet.

    Problem Statement: 1.WAP to display hello, Welcome to servlet in servlet.2. WAP to display data of the student from database (mysql) in

    servlet.

    3. WAP to get the html document in servelet.

    Requirement: Notepad, Internet Explorer, Appache server, mysql

    Theory:

    HTML Forms, Components, and Servlets

    This document is to give you a brief overview of HTML forms, components, and

    servlets. The big picture is that you create a form on a web page. When a user completes

    the form, the data that the user entered is sent to a servlet for processing. A servlet is ajava class (or object) whose doPost or doGet method is invoked (as prescribed by the

    form). The servlet reads the submitted data, and outputs text or a new web page as a

    result. In this document, I show how servlets can output either pure text or a web page as

    a result.

    What is a Servlet?

    Servlets are modules of Java code that run in a server application (hence the name

    "Servlets", similar to "Applets" on the client side) to answer client requests. Servlets arenot tied to a specific client-server protocol but they are most commonly used with HTTP

    and the word "Servlet" is often used in the meaning of "HTTP Servlet".

    Servlets make use of the Java standard extension classes in the packages javax.servlet

    (the basic Servlet framework) and javax.servlet.http (extensions of the Servlet framework

    for Servlets that answer HTTP requests). Since Servlets are written in the highly portable

  • 8/14/2019 WE Expriment Manual1

    11/40

    Java language and follow a standard framework, they provide a means to create

    sophisticated server extensions in a server and operating system independent way.

    Typical uses for HTTP Servlets include:

    Processing and/or storing data submitted by an HTML form. Providing dynamic content, e.g. returning the results of a database query to the

    client.

    Managing state information on top of the stateless HTTP, e.g. for an onlineshopping cart system which manages shopping carts for many concurrent

    customers and maps every request to the right customer.

    Servlets vs CGI

    The traditional way of adding functionality to a Web Server is the Common Gateway

    Interface (CGI), a language-independent interface that allows a server to start an external

    process which gets information about a request through environment variables, thecommand line and its standard input stream and writes response data to its standard

    output stream. Each request is answered in a separate process by a separate instance of

    the CGI program, or CGI script (as it is often called because CGI programs are usuallywritten in interpreted languages like Perl).

    Servlets have several advantages over CGI:

    A Servlet does not run in a separate process. This removes the overhead of

    creating a new process for each request.

    A Servlet stays in memory between requests. A CGI program (and probably alsoan extensive runtime system or interpreter) needs to be loaded and started for each

    CGI request.

    There is only a single instance which answers all requests concurrently. Thissaves memory and allows a Servlet to easily manage persistent data.

    A Servlet can be run by a Servlet Engine in a restrictiveSandbox (just like an

    Applet runs in a Web Browser's Sandbox) which allows secure use of untrustedand potentially harmful Servlets.

    1.3 The Basic Servlet Architecture

    A Servlet, in its most general form, is an instance of a class which implements thejavax.servlet.Servlet interface. Most Servlets, however, extend one of the standard

    implementations of that interface, namely javax.servlet.GenericServlet and

    javax.servlet.http.HttpServlet. In this tutorial we'll be discussing only HTTP Servletswhich extend the javax.servlet.http.HttpServlet class.

    In order to initialize a Servlet, a server application loads the Servlet class (and probably

    other classes which are referenced by the Servlet) and creates an instance by calling the

    http://hoohoo.ncsa.uiuc.edu/cgi/overview.htmlhttp://hoohoo.ncsa.uiuc.edu/cgi/overview.htmlhttp://hoohoo.ncsa.uiuc.edu/cgi/overview.htmlhttp://www.novocode.com/doc/servlet-essentials/appendix.html#a_d_Sandboxhttp://www.novocode.com/doc/servlet-essentials/appendix.html#a_d_Sandboxhttp://hoohoo.ncsa.uiuc.edu/cgi/overview.htmlhttp://hoohoo.ncsa.uiuc.edu/cgi/overview.htmlhttp://www.novocode.com/doc/servlet-essentials/appendix.html#a_d_Sandbox
  • 8/14/2019 WE Expriment Manual1

    12/40

    no-args constructor. Then it calls the Servlet's init(ServletConfig config) method. The

    Servlet should performe one-time setup procedures in this method and store the

    ServletConfig object so that it can be retrieved later by calling the Servlet'sgetServletConfig() method. This is handled by GenericServlet. Servlets which extend

    GenericServlet (or its subclass HttpServlet) should call super.init(config) at the beginning

    of the init method to make use of this feature. The ServletConfig object contains Servletparameters and a reference to the Servlet's ServletContext. The init method is guaranteed

    to be called only once during the Servlet's lifecycle. It does not need to be thread-safe

    because the service method will not be called until the call to init returns.

    When the Servlet is initialized, its service(ServletRequest req, ServletResponse res)method is called for every request to the Servlet. The method is called concurrently (i.e.

    multiple threads may call this method at the same time) so it should be implemented in a

    thread-safe manner. Techniques for ensuring that the service method is not calledconcurrently, for the cases where this is not possible, are described in section 4.1.

    When the Servlet needs to be unloaded (e.g. because a new version should be loaded orthe server is shutting down) the destroy() method is called. There may still be threads that

    execute the service method when destroy is called, so destroy has to be thread-safe. Allresources which were allocated in init should be released in destroy. This method is

    guaranteed to be called only once during the Servlet's lifecycle.

    Servlet Methods:

    A Generic servlet contains the following five methods:

    init()

    public void init(ServletConfig config) throws ServletException

    The init() method is called only once by the servlet container throughout the life of a

    servlet. By this init() method the servlet get to know that it has been placed intoservice.

    The servlet cannot be put into the service if

    The init() method does not return within a fix time set by the web server.

    It throws a ServletException

    Parameters - The init() method takesa ServletConfig object that contains theinitialization parameters and servlet's configuration and throws a ServletException if

    an exception has occurred.

    service()

    public void service(ServletRequest req, ServletResponse res) throws

    ServletException, IOException

    http://www.novocode.com/doc/servlet-essentials/chapter4a.html#ch_4_1http://www.novocode.com/doc/servlet-essentials/chapter4a.html#ch_4_1
  • 8/14/2019 WE Expriment Manual1

    13/40

    Once the servlet starts getting the requests, the service() method is called by the servlet

    container to respond. The servlet services the client's request with the help of twoobjects. These two objectsjavax.servlet.ServletRequest and

    javax.servlet.ServletResponse are passed by the servlet container.

    The status code of the response always should be set for a servlet that throws or sends

    an error.

    Parameters - The service() method takes the ServletRequest object that contains the

    client's request and the object ServletResponse contains the servlet's response. The

    service() method throws ServletException and IOExceptions exception.

    getServletConfig()

    public ServletConfig getServletConfig()

    This method contains parameters for initialization and startup of the servlet and returnsa ServletConfig object. This object is then passed to the init method. When this

    interface is implemented then it stores the ServletConfig object in order to return it. It

    is done by the generic class which implements this inetrface.

    Returns - the ServletConfig object

    getServletInfo()

    public String getServletInfo()

    The information about the servlet is returned by this method like version, author etc.

    This method returns a string which should be in the form of plain text and not any kindof markup.

    Returns - a string that contains the information about the servlet

    destroy()

    public void destroy()

    This method is called when we need to close the servlet. That is before removing aservlet instance from service, the servlet container calls the destroy() method. Once the

    servlet container calls the destroy() method, no service methods will be then called .

    That is after the exit of all the threads running in the servlet, the destroy() method is

    called. Hence, the servlet gets a chance to clean up all the resources like memory,threads etc which are being held.

  • 8/14/2019 WE Expriment Manual1

    14/40

    A typical Servlet lifecycle

    1.4 HTTP

    Before we can start writing the first Servlet, we need to know some basics of HTTP

    ("HyperText Transfer Protocol"), the protocol which is used by a WWW client (e.g. abrowser) to send a request to a Web Server.

    HTTP is a request-response oriented protocol. An HTTP request consists of a request

    method, a URI, header fields and a body (which can be empty). An HTTP response

    contains a result code and again header fields and a body.

    The service method of HttpServlet dispatches a request to different Java methods for

    different HTTP request methods. It recognizes the standard HTTP/1.1 methods and

    should not be overridden in subclasses unless you need to implement additional methods.

    The recognized methods are GET, HEAD, PUT, POST, DELETE, OPTIONS andTRACE. Other methods are answered with aBad RequestHTTP error. An HTTP method

    XXXis dispatched to a Java method doXxx, e.g. GET-> doGet. All these methods expect

    the parameters "(HttpServletRequest req, HttpServletResponse res)". The methodsdoOptions and doTrace have suitable default implementations and are usually not

    overridden. The HEAD method (which is supposed to return the same header lines that a

    GET method would return, but doesn't include a body) is performed by calling doGet and

    ignoring any output that is written by this method. That leaves us with the methodsdoGet, doPut, doPost and doDelete whose default implementations in HttpServlet return

    aBad RequestHTTP error. A subclass ofHttpServlet overrides one or more of these

    methods to provide a meaningful implementation.

    The request data is passed to all methods through the first argument of type

    HttpServletRequest (which is a subclass of the more general ServletRequest class). The

  • 8/14/2019 WE Expriment Manual1

    15/40

    response can be created with methods of the second argument of type

    HttpServletResponse (a subclass of ServletResponse).

    When you request a URL in a Web Browser, the GET method is used for the request. AGET request does not have a body (i.e. the body is empty). The response should contain a

    body with the response data and header fields which describe the body (especiallyContent-Type and Content-Encoding). When you send an HTML form, either GET or

    POST can be used. With a GET request the parameters are encoded in the URL, with aPOST request they are transmited in the body. HTML editors and upload tools use PUT

    requests to upload resources to a Web Server and DELETE requests to delete resources.

    Conclusion: Thus we studied in detail servlet.

  • 8/14/2019 WE Expriment Manual1

    16/40

    Expriment No.4

    Aim: To Study of DHTML:CSS

    Problem Statement: 1.WAP on inline stylesheet .2. WAP on external stylesheet

    3. WAP to style element.

    Requirement: Notepad, Internet Explorer

    Theory:DHTML is NOT a language. It is a TERM describing the art of making

    dynamic and interactive web pages. DHTML combines HTML, JavaScript, DOM, and

    CSS is the W3C standard style and layout model for HTML.CSS allows web developers

    to control the style and layout of web pages.HTML 4 allows dynamic changes toCSS.DHTML is about using JavaScript and DOM to change the style and positioning of

    HTML elements.

    CSS Tutorial:Using In-line Style This page is a CSS tutorial about how to use in-line stylesheets rules.

    In-line CSS Style rules take precedence over internal CSS Style Sheets rules. The internal

    CSS style sheet (template) takes precedence over any external CSS style sheets rules. Thelowest on the totem pole is the external style sheet (template), also called the external

    CSS style sheets rules. The highest in the hierarchy is the in-line STYLE property which

    can be added to a tag, such as

    .

    In this paragraph the text will take on the properties of the internal CSS style,

    CLASS="micro". If no internal Cascading Style Sheets rules have been established the

    external CSS style will be used, if you created a text file for the external Cascading StyleSheets rules. If no CSS is used, your Web page will be rendered by the default settings of

    the user's browser.

    If you find yourself using in-line styles a lot, you will want to consider making a new

    class to handle any style that you are using repeatedly. Place it into an internal or external

    style sheet rather than in-line style. In-line style was only meant for very occasional use.Oh, and I get lazy and use it more than I should at times, so I will consiously try to clean

    up my own faults, too. This is how it is done:

    Let's say for some reason that your internal style sheet (persistent style) has specified all

    of your H3 headings as blue and you need on to be a more subtle orange color. In theBODY of the HTML document when you want this change to occur, you would code

  • 8/14/2019 WE Expriment Manual1

    17/40

    just as if everything within the quotes is an actual declaration from a regular style sheet.

    The quotes are required. Use semi-colons again if using more than one declaration.

    Preceed the in-line style with STYLE = after the opening HTML "tag" and the entire in-line style is coded before closing the first "tag".

    Another example of in-line occurs when you want to change only the left and rightmargins of one paragraph.

    [text]

    For any element in HTML that has a STYLE attribute, you may use in-line style ratherthan the internal style sheets rule.. Any inline style rule supercedes and over-rides the

    internal style sheets rule. The internal style sheets rules however still supercede and over-

    ride the external style sheets rules. This is the reason they are called Cascading StyleSheets... their heirarchy flows from the external (least important), to the internal, and one

    down to the in-line style sheets rule (most important in that in over-rides all the other

    rules for the element).

  • 8/14/2019 WE Expriment Manual1

    18/40

    Experiment No.5

    Aim: To Study of XML.

    Problem Statement: 1.WAP to create simple xml.2. WAP to create simple xml with html.

    Requirement: Notepad, Internet Explorer

    Theory:

    What is XML?

    "XML is a cross-platform, software and hardware independent

    tool for transmitting information"

    XML is a W3C Recommendations. It stands for Extensible MarkupLanguage . It is a markup language much like HTML used to describe

    data. In XML, tags are not predefined. A user defines his own tagsand XML document structure like Document Type Definition (DTD) ,

    XML Schema to describe the data. Hence it is self-descriptivetoo.There is Nothing Special About XML It is just plain text with

    the addition of some XML tags enclosed in angle brackets. In a simple

    text editor, the XML document is easily visible .

    Why Is XML So Important?

    There are number of reasons that contributes to the XML's increasing

    acceptance , few of them are:

  • 8/14/2019 WE Expriment Manual1

    19/40

    Plain Text

    In XML it is easy to create and edit files with anything from a standard

    text editor to a visual development environment. XML also provides

    scalability for anything from small configuration files to a company-

    wide data repository.

    Data Identification

    The markup tags in XML documents identifiy the information and breakup the data into parts for example.. a search program can look for

    messages sent to particular people from the rest of the message.Different parts of the information are identified and further they can

    be used in different ways by different applications.

    Stylability

    When display matters, the stylesheet standard, XSL (an advancefeature of XML), lets you dictate over the convectional designs ( like

    using HTML) to portray the data. XML being style-free, uses differentstylesheets to produce output in postscript, TEX, PDF, or some new

    format that hasn't even been invented yet. A user can use a simple

    XML document to display data in diverse formats like

    a plain text file

    an XHTML file

    a WML (Wireless Markup Language) document suitable for display on a PDA

    an Adobe PDF document suitable for hard copy

    a VML (Voice Markup Language) dialog for a voicemail information system

    an SVG (Scalable Vector Graphic) document that draws pictures of thermometers and

    water containers

    Universally Processed

    Apart from being valid , restrictions are imposed on a xml file to abideby a DTD or a Schema to make it well-formed .Otherwise, the XML

    parser won't be able to read the data. XML is a vendor-neutralstandard, so a user can choose among several XML parsers to process

    XML data.

    Hierarchical Approach

    XML documents get benefitted from their hierarchical structure.Hierarchical document structures are, faster to access. They are also

  • 8/14/2019 WE Expriment Manual1

    20/40

    easier to rearrange, because each piece is delimited. This makes xmlfiles easy to modify and maintain.

    Inline Reusabiliy

    XML documents can be composed of separate entities. XML entitiescan be included "in line" in a XML document. And this included sections

    look like a normal part of the document .A user can single-source a

    section so that an edit to it is reflected everywhere the section is used,and yet a document composed looks like a one-piece document.

    How Can You Use XML?

    Few Applications of XML

    Although there are countless applications that use XML, here are afew examples of the applications that are making use of this

    technology.

    Refined search results - With XML-specific tags, search engines cangive users more refined search results. A search engine seeks the term

    in the tags, rather than the entire document, giving the user moreprecise results.

    EDI Transactions - XML has made electronic data interchange (EDI)

    transactions accessible to a broader set of users. XML allows data to

    be exchanged, regardless of the computing systems or accountingapplications being used.

    Cell Phones - XML data is sent to some cell phones, which is thenformatted by the specification of the cell phone software designer to

    display text, images and even play sounds!

    File Converters - Many applications have been written to convert existing documents

    into the XML standard. An example is a PDF to XML converter.

    VoiceXML - Converts XML documents into an audio format so that a

    user can listen to an XML document.

    Comparing XML with HTML

    The Main Differences Between XML and HTML

    XML is designed to carry data.

  • 8/14/2019 WE Expriment Manual1

    21/40

    XML describes and focuses on the data while HTML only displays and focuses on

    how data looks. HTML is all about displaying information but XML is all about

    describing information. In current scenario XML is the most common tool for datamanipulation and data transmission.

    XML is used to store data in files and for sharing data between diverse applications.

    Unlike HTML document where data and display logic are available in the same file,XML hold only data. Different presentation logics could be applied to display the xmldata in the required format. XML is the best way to exchange information.

    XML is Free and Extensible

    XML tags are not predefined. User must "invent" his tags.

    The tags used to mark up HTML documents and the structure of HTML documents are

    predefined. The author of HTML documents can only use tags that are defined in theHTML standard (like

    , , etc.).

    XML allows the user to define his own tags and document structure.

    XML Tags are Case Sensitive

    Unlike HTML, XML tags are case sensitive.In HTML the following will work:

    This is incorrect

    In XML opening and closing tags must therefore be written with the same case:

    This is correct

  • 8/14/2019 WE Expriment Manual1

    22/40

    The syntax rules for XML are very simple and strict. These are easy to learn and

    use. Because of this, creating software that can read and manipulate XML is very easy.

    Xml enables an user to create his own tags.

    Note - XML documents use a self-describing and simple syntax

    Let's develop a simple XML document :

    RohanAmit

    Surprise....

    Be ready for a cruise...i will catch u tonight

    The XML declaration: Always the first line in the xml document:

    The XML declaration should always be included. It defines the XML

    version and the character encoding used in the document. In this casethe document conforms to the 1.0 specification of XML and uses the

    ISO-8859-1 (Latin-1/West European) character set.

    Root Element: The next line defines the first element of thedocument . It is called as the root element

    Child Elements: The next 4 lines describe the four child elements of

    the root (To, From, Subject and Body).

    Rohan

    Amit

    Surprise....Be ready for a cruise...i will catch u

    tonight

    And finally the last line defines the end of the root element .

  • 8/14/2019 WE Expriment Manual1

    23/40

    you may feel from this example that the XML document contains a E-mail To Rohan From Amit. Don't you agree that XML is quite self-

    descriptive?

    Now let's discuss its syntax-rules which are very simple to learn.

    All XML elements must have a closing tag

    In XML all the elements must have a closing tag like this:

    RohanAmit

    XML tags are case sensitive

    XML tags are case sensitive. The tag is different from the tag.Hence the opening and closing tags must be written with the

    same case:

    Rohan

    Rohan

    XML Elements Must be Properly Nested

    Improper nesting of tags makes no sense to XML. In XML all

    elements must be properly nested within each other like this in a

    logical order:

    Hi , how are you.....

    XML Documents Must Have a Root Element

    All XML documents must contain a single tag pair to define a rootelement. All other elements must be written within this root element.

    All elements can have sub elements called as child elements. Subelements must be correctly nested within their parent element:

    .....

  • 8/14/2019 WE Expriment Manual1

    24/40

    Always Quote the XML Attribute Values

    In XML the attribute value must always be quoted. XML elements can

    have attributes in name/value pairs just like in HTML. Just look the two

    XML documents below.

    The error in the first document is that the date and version attributes are not quoted .

    The second document is correct:

    With XML, White Space is Preserved

    With XML, the white space in a document is preserved .

    So a sentence like this : Hello How are you, will be

    displayed like this:

    Hello How are you,

    Comments in XML

    The syntax for writing comments in XML is similar to that of HTML.

    XML Elements are extensible. They have relationships. They have simple naming

    rules.

    XML Element

    XML Elements are Extensible

    XML documents can be extended to carry more information.

  • 8/14/2019 WE Expriment Manual1

    25/40

    Look at the following XML example:

    Rohan

    Amit

    Be ready for a cruise...i will catch u tonight

    Let's suppose that we create an application to fetch data from theabove XML document and produce this output:

    E-mail

    To: Rohan

    From: Amit

    Be ready for a cruise...i will catch utonight

    Now, the author wants to add a new feature (let it be a subject line).

    He can easily achieve it by adding one more tag ie..in thexml document. So the new modified xml document will look like this :

    Rohan

    AmitSurprise....

    Be ready for a cruise...i will catch u tonight

    Now the new generated output will look like this

    E-mail

    To: Rohan

    From: Amit

    Subject : Surprise....

    Be ready for a cruise...i will catch u

    tonight

  • 8/14/2019 WE Expriment Manual1

    26/40

    XML Elements have Relationships

    Elements in a xml document are related as parents and

    children.

    Imagine that this xml document is a description of a e-mail:

    RohanAmit

    Surprise....

    Be ready for a cruise...i will catch utonight

    Here, E-mail is the root element while To, From, Subject and Body arethe child elements of the E-mail. Here, E-mail is the parent element

    of To, From, Subject and Body. To, From, Subject and Body aresiblings (or sister elements) because they have the same parentage.

    Hence , all the XML Elements have Relationships.

    XML Element Naming : Know-hows

    XML elements must follow these naming conventions:

    Names must not start with a number or punctuation character but it can contain letters,numbers, and other characters without spaces. Names must not start with the letters xml

    (or XML, or Xml, etc)

    XML Attributes

    XML elements can have attributes in the start tag, just like HTML. Attributes are used to

    provide additional information about elements. Attributes often provide information thatis not a part of the data. In the example below, the file type is irrelevant to the data, but

    important to the software that wants to manipulate the element:

    roseindia.gif

    Use the quote styles: "red" or 'red'Attribute values must always be enclosed in quotes. Use either single or double quotes

    eg..

  • 8/14/2019 WE Expriment Manual1

    27/40

    or like this:

    Note: If the attribute value itself contains double quotes it is necessary to use singlequotes, like in this example:

    Note: If the attribute value itself contains single quotes it is necessary to use double

    quotes, like in this example:

    Use of Elements vs. Attributes

    If you start using attributes as containers for XML data, you might end up with the

    documents that are both difficult to maintain and manipulate. So the user should useelements to describe the data. Use attributes only to provide data that is not relevant to

    the reader. Only metadata (data about data) should be stored as attributes, and that data

    itself should be stored as elements.

    This is not the way to use attributes eg..

  • 8/14/2019 WE Expriment Manual1

    28/40

  • 8/14/2019 WE Expriment Manual1

    29/40

    Theory:

    Introduction

    This specification defines the syntax and semantics of the XSLT language. A

    transformation in the XSLT language is expressed as a well-formed XML document

    [XML] conforming to the Namespaces in XML Recommendation [XML Names], whichmay include both elements that are defined by XSLT and elements that are not defined by

    XSLT. XSLT-defined elements are distinguished by belonging to a specific XML

    namespace (see [2.1 XSLT Namespace]), which is referred to in this specification as the

    XSLT namespace. Thus this specification is a definition of the syntax and semantics of

    the XSLT namespace.

    A transformation expressed in XSLT describes rules for transforming a source tree into a

    result tree. The transformation is achieved by associating patterns with templates. Apattern is matched against elements in the source tree. A template is instantiated to create

    part of the result tree. The result tree is separate from the source tree. The structure of the

    result tree can be completely different from the structure of the source tree. Inconstructing the result tree, elements from the source tree can be filtered and reordered,

    and arbitrary structure can be added.

    A transformation expressed in XSLT is called a stylesheet. This is because, in the case

    when XSLT is transforming into the XSL formatting vocabulary, the transformationfunctions as a stylesheet.

    This document does not specify how an XSLT stylesheet is associated with an XML

    document. It is recommended that XSL processors support the mechanism described in

    [XML Stylesheet]. When this or any other mechanism yields a sequence of more thanone XSLT stylesheet to be applied simultaneously to a XML document, then the effect

    should be the same as applying a single stylesheet that imports each member of the

    sequence in order (see [2.6.2 Stylesheet Import]).

    A stylesheet contains a set of template rules. A template rule has two parts: a patternwhich is matched against nodes in the source tree and a template which can be

    instantiated to form part of the result tree. This allows a stylesheet to be applicable to a

    wide class of documents that have similar source tree structures.

    A template is instantiated for a particular source element to create part of the result tree.

    A template can contain elements that specify literal result element structure. A templatecan also contain elements from the XSLT namespace that are instructions for creating

    result tree fragments. When a template is instantiated, each instruction is executed andreplaced by the result tree fragment that it creates. Instructions can select and process

    descendant source elements. Processing a descendant element creates a result tree

    fragment by finding the applicable template rule and instantiating its template. Note thatelements are only processed when they have been selected by the execution of an

    http://www.w3.org/TR/xslt#XML%23XMLhttp://www.w3.org/TR/xslt#XMLNAMES%23XMLNAMEShttp://www.w3.org/TR/xslt#XMLNAMES%23XMLNAMEShttp://www.w3.org/TR/xslt#xslt-namespace%23xslt-namespacehttp://www.w3.org/TR/xslt#xslt-namespace%23xslt-namespacehttp://www.w3.org/TR/xslt#xslt-namespace%23xslt-namespacehttp://www.w3.org/TR/xslt#xslt-namespace%23xslt-namespacehttp://www.w3.org/TR/xslt#XMLSTYLE%23XMLSTYLEhttp://www.w3.org/TR/xslt#import%23importhttp://www.w3.org/TR/xslt#import%23importhttp://www.w3.org/TR/xslt#import%23importhttp://www.w3.org/TR/xslt#import%23importhttp://www.w3.org/TR/xslt#XML%23XMLhttp://www.w3.org/TR/xslt#XMLNAMES%23XMLNAMEShttp://www.w3.org/TR/xslt#xslt-namespace%23xslt-namespacehttp://www.w3.org/TR/xslt#XMLSTYLE%23XMLSTYLEhttp://www.w3.org/TR/xslt#import%23import
  • 8/14/2019 WE Expriment Manual1

    30/40

    instruction. The result tree is constructed by finding the template rule for the root node

    and instantiating its template.

    In the process of finding the applicable template rule, more than one template rule mayhave a pattern that matches a given element. However, only one template rule will be

    applied. Single template by itself has considerable power: it can create structures ofarbitrary complexity; it can pull string values out of arbitrary locations in the source tree;

    it can generate structures that are repeated according to the occurrence of elements in thesource tree. For simple transformations where the structure of the result tree is

    independent of the structure of the source tree, a stylesheet can often consist of only a

    single template, which functions as a template for the complete result tree.Transformations on XML documents that represent data are often of this kind. XSLT

    allows a simplified syntax for such stylesheets.

    When a template is instantiated, it is always instantiated with respect to a current node

    and a current node list. The current node is always a member of the current node list.

    Many operations in XSLT are relative to the current node. Only a few instructions changethe current node list or the current node (see [5 Template Rules] and[8 Repetition]);

    during the instantiation of one of these instructions, the current node list changes to a newlist of nodes and each member of this new list becomes the current node in turn; after the

    instantiation of the instruction is complete, the current node and current node list revert to

    what they were before the instruction was instantiated.

    XSLT makes use of the expression language defined by [XPath] for selecting elementsfor processing, for conditional processing and for generating text.

    XSLT provides two "hooks" for extending the language, one hook for extending the set

    of instruction elements used in templates and one hook for extending the set of functionsused in XPath expressions. These hooks are both based on XML namespaces. Thisversion of XSLT does not define a mechanism for implementing the hooks..

    The element syntax summary notation used to describe the syntax of XSLT-defined

    elements is described .The MIME media types text/xml and application/xml [RFC2376]

    should be used for XSLT stylesheets. It is possible that a media type will be registeredspecifically for XSLT stylesheets; if and when it is, that media type may also be used.

    2 Stylesheet Structure

    XSLT Namespace

    The XSLT namespace has the URI http://www.w3.org/1999/XSL/Transform.

    NOTE:The 1999 in the URI indicates the year in which the URI was allocated by the

    W3C. It does not indicate the version of XSLT being used, which is specified byattributes (see Stylesheet Element] and [Literal Result Element as Stylesheet]).

    http://www.w3.org/TR/xslt#rules%23ruleshttp://www.w3.org/TR/xslt#rules%23ruleshttp://www.w3.org/TR/xslt#rules%23ruleshttp://www.w3.org/TR/xslt#rules%23ruleshttp://www.w3.org/TR/xslt#for-each%23for-eachhttp://www.w3.org/TR/xslt#for-each%23for-eachhttp://www.w3.org/TR/xslt#for-each%23for-eachhttp://www.w3.org/TR/xslt#for-each%23for-eachhttp://www.w3.org/TR/xslt#for-each%23for-eachhttp://www.w3.org/TR/xslt#XPATH%23XPATHhttp://www.w3.org/TR/xslt#RFC2376%23RFC2376http://www.w3.org/TR/xslt#stylesheet-element%23stylesheet-elementhttp://www.w3.org/TR/xslt#stylesheet-element%23stylesheet-elementhttp://www.w3.org/TR/xslt#stylesheet-element%23stylesheet-elementhttp://www.w3.org/TR/xslt#result-element-stylesheet%23result-element-stylesheethttp://www.w3.org/TR/xslt#result-element-stylesheet%23result-element-stylesheethttp://www.w3.org/TR/xslt#result-element-stylesheet%23result-element-stylesheethttp://www.w3.org/TR/xslt#result-element-stylesheet%23result-element-stylesheethttp://www.w3.org/TR/xslt#rules%23ruleshttp://www.w3.org/TR/xslt#for-each%23for-eachhttp://www.w3.org/TR/xslt#XPATH%23XPATHhttp://www.w3.org/TR/xslt#RFC2376%23RFC2376http://www.w3.org/TR/xslt#stylesheet-element%23stylesheet-elementhttp://www.w3.org/TR/xslt#result-element-stylesheet%23result-element-stylesheet
  • 8/14/2019 WE Expriment Manual1

    31/40

    XSLT processors must use the XML namespaces mechanism [XML Names]to recognize

    elements and attributes from this namespace. Elements from the XSLT namespace are

    recognized only in the stylesheet not in the source document. The complete list of XSLT-defined elements is specified in [B Element Syntax Summary]. Vendors must not

    extend the XSLT namespace with additional elements or attributes. Inst that is used for

    additional instruction elements must be identified by means of the extension elementmechanism specified in [ Extension Elements].

    This specification uses a prefix of xsl: for referring to elements in the XSLT namespace.

    However, XSLT stylesheets are free to use any prefix, provided that there is a namespace

    declaration that binds the prefix to the URI of the XSLT namespace.

    An element from the XSLT namespace may have any attribute not from the XSLTnamespace, provided that the expanded-name of the attribute has a non-null namespace

    URI. The presence of such attributes must not change the behavior of XSLT elements

    and functions defined in this document. Thus, an XSLT processor is always free to ignore

    such attributes, and must ignore such attributes without giving an error if it does notrecognize the namespace URI. Such attributes can provide, for example, unique

    identifiers, optimization hints, or documentation.

    It is an error for an element from the XSLT namespace to have attributes with expanded-names that have null namespace URIs (i.e. attributes with unprefixed names) other than

    attributes defined for the element in this document.

    2.2 Stylesheet Element

    A stylesheet is represented by an xsl:stylesheet element in an XML document.

    xsl:transform is allowed as a synonym for xsl:stylesheet.

    http://www.w3.org/TR/xslt#XMLNAMES%23XMLNAMEShttp://www.w3.org/TR/xslt#XMLNAMES%23XMLNAMEShttp://www.w3.org/TR/xslt#element-syntax-summary%23element-syntax-summaryhttp://www.w3.org/TR/xslt#element-syntax-summary%23element-syntax-summaryhttp://www.w3.org/TR/xslt#element-syntax-summary%23element-syntax-summaryhttp://www.w3.org/TR/xslt#element-syntax-summary%23element-syntax-summaryhttp://www.w3.org/TR/xslt#extension-element%23extension-elementhttp://www.w3.org/TR/xslt#extension-element%23extension-elementhttp://www.w3.org/TR/xslt#extension-element%23extension-elementhttp://www.w3.org/TR/xslt#extension-element%23extension-elementhttp://www.w3.org/TR/xslt#extension-element%23extension-elementhttp://www.w3.org/TR/xpath#dt-expanded-namehttp://www.w3.org/TR/xslt#element-import%23element-importhttp://www.w3.org/TR/xslt#element-import%23element-importhttp://www.w3.org/TR/xslt#XMLNAMES%23XMLNAMEShttp://www.w3.org/TR/xslt#element-syntax-summary%23element-syntax-summaryhttp://www.w3.org/TR/xslt#extension-element%23extension-elementhttp://www.w3.org/TR/xpath#dt-expanded-namehttp://www.w3.org/TR/xslt#element-import%23element-importhttp://www.w3.org/TR/xslt#element-import%23element-import
  • 8/14/2019 WE Expriment Manual1

    32/40

    An xsl:stylesheet element must have a version attribute, indicating the version of XSLT

    that the stylesheet requires. For this version of XSLT, the value should be 1.0. When the

    value is not equal to 1.0, forwards-compatible processing mode is enabled Thexsl:stylesheet element may contain the following types of elements:

    xsl:import xsl:include

    xsl:strip-space xsl:preserve-space

    xsl:output

    xsl:key

    xsl:decimal-format

    xsl:namespace-alias

    xsl:attribute-set

    xsl:variable

    xsl:param

    xsl:template

    An element occurring as a child of an xsl:stylesheet element is called a top-level element.

    This example shows the structure of a stylesheet. Ellipses (...) indicate where attributevalues or content have been omitted. Although this example shows one of each type of

    allowed element, stylesheets may contain zero or more of each of these elements.

    ...

  • 8/14/2019 WE Expriment Manual1

    33/40

    ...

    ...

    ...

    ...

    The order in which the children of the xsl:stylesheet element occur is not significant

    except for xsl:import elements and for error recovery. Users are free to order the elements

    as they prefer, and stylesheet creation tools need not provide control over the order inwhich the elements occur.

    In addition, the xsl:stylesheet element may contain any element not from the XSLT

    namespace, provided that the expanded-name of the element has a non-null namespace

    URI. The presence of such top-level elements must not change the behavior of XSLTelements and functions defined in this document; for example, it would not be permitted

    for such a top-level element to specify that xsl:apply-templates was to use different rules

    to resolve conflicts. Thus, an XSLT processor is always free to ignore such top-level

    elements, and must ignore a top-level element without giving an error if it does notrecognize the namespace URI. Such elements can provide, for example,

    information used by extension elements or extension functions (see [14Extensions]),

    information about what to do with the result tree, information about how to obtain the source tree,

    metadata about the stylesheet,

    structured documentation for the stylesheet.

    2.3 Literal Result Element as Stylesheet

    A simplified syntax is allowed for stylesheets that consist of only a single template for

    the root node. The stylesheet may consist of just a literal result element (see [7.1.1Literal Result Elements]). Such a stylesheet is equivalent to a stylesheet with an

    xsl:stylesheet element containing a template rule containing the literal result element; the

    template rule has a match pattern of /. For example

    http://www.w3.org/TR/xslt#extension%23extensionhttp://www.w3.org/TR/xslt#extension%23extensionhttp://www.w3.org/TR/xslt#extension%23extensionhttp://www.w3.org/TR/xslt#extension%23extensionhttp://www.w3.org/TR/xslt#extension%23extensionhttp://www.w3.org/TR/xslt#literal-result-element%23literal-result-elementhttp://www.w3.org/TR/xslt#literal-result-element%23literal-result-elementhttp://www.w3.org/TR/xslt#literal-result-element%23literal-result-elementhttp://www.w3.org/TR/xslt#literal-result-element%23literal-result-elementhttp://www.w3.org/TR/xslt#literal-result-element%23literal-result-elementhttp://www.w3.org/TR/xslt#extension%23extensionhttp://www.w3.org/TR/xslt#extension%23extensionhttp://www.w3.org/TR/xslt#literal-result-element%23literal-result-elementhttp://www.w3.org/TR/xslt#literal-result-element%23literal-result-element
  • 8/14/2019 WE Expriment Manual1

    34/40

  • 8/14/2019 WE Expriment Manual1

    35/40

    2.4 Qualified Names

    The name of an internal XSLT object, specifically a named template (see NamedTemplates]), a mode (see [ Modes]), an attribute set (see[Named Attribute Sets]), akey (see [12.2 Keys]), a decimal-format (see[ Number Formatting]), a variable or a

    parameter (see [ Variables and Parameters]) is specified as a QName. If it has a prefix,then the prefix is expanded into a URI reference using the namespace declarations in

    effect on the attribute in which the name occurs. The expanded-nameconsisting of thelocal part of the name and the possibly null URI reference is used as the name of the

    object. The default namespace is notused for unprefixed names.

    2.5 Forwards-Compatible Processing

    An element enables forwards-compatible mode for itself, its attributes, its descendantsand their attributes if either it is an xsl:stylesheet element whose version attribute is not

    equal to 1.0, or it is a literal result element that has an xsl:version attribute whose value is

    not equal to 1.0, or it is a literal result element that does not have an xsl:version attributeand that is the document element of a stylesheet using the simplified syntax (see [Literal

    Result Element as Stylesheet]). A literal result element that has an xsl:version attribute

    whose value is equal to 1.0 disables forwards-compatible mode for itself, its attributes, its

    descendants and their attributes.

    If an element is processed in forwards-compatible mode, then:

    if it is atop-level element and XSLT 1.0 does not allow such elements as top-

    level elements, then the element must be ignored along with its content;

    if it is an element in a template and XSLT 1.0 does not allow such elements to

    occur in templates, then if the element is not instantiated, an error must not besignaled, and if the element is instantiated, the XSLT must perform fallback for

    the element as specified in [ Fallback];

    if the element has an attribute that XSLT 1.0 does not allow the element to have

    or if the element has an optional attribute with a value that the XSLT 1.0 does not

    allow the attribute to have, then the attribute must be ignored.

    Thus, any XSLT 1.0 processor must be able to process the following stylesheet withouterror, although the stylesheet includes elements from the XSLT namespace that are not

    defined in this specification:

    http://www.w3.org/TR/xslt#named-templates%23named-templateshttp://www.w3.org/TR/xslt#named-templates%23named-templateshttp://www.w3.org/TR/xslt#named-templates%23named-templateshttp://www.w3.org/TR/xslt#named-templates%23named-templateshttp://www.w3.org/TR/xslt#modes%23modeshttp://www.w3.org/TR/xslt#modes%23modeshttp://www.w3.org/TR/xslt#modes%23modeshttp://www.w3.org/TR/xslt#modes%23modeshttp://www.w3.org/TR/xslt#attribute-sets%23attribute-setshttp://www.w3.org/TR/xslt#attribute-sets%23attribute-setshttp://www.w3.org/TR/xslt#attribute-sets%23attribute-setshttp://www.w3.org/TR/xslt#attribute-sets%23attribute-setshttp://www.w3.org/TR/xslt#attribute-sets%23attribute-setshttp://www.w3.org/TR/xslt#key%23keyhttp://www.w3.org/TR/xslt#key%23keyhttp://www.w3.org/TR/xslt#key%23keyhttp://www.w3.org/TR/xslt#key%23keyhttp://www.w3.org/TR/xslt#format-number%23format-numberhttp://www.w3.org/TR/xslt#format-number%23format-numberhttp://www.w3.org/TR/xslt#format-number%23format-numberhttp://www.w3.org/TR/xslt#format-number%23format-numberhttp://www.w3.org/TR/xslt#format-number%23format-numberhttp://www.w3.org/TR/xslt#variables%23variableshttp://www.w3.org/TR/xslt#variables%23variableshttp://www.w3.org/TR/xslt#variables%23variableshttp://www.w3.org/TR/xslt#variables%23variableshttp://www.w3.org/TR/REC-xml-names#NT-QNamehttp://www.w3.org/TR/REC-xml-names#NT-QNamehttp://www.w3.org/TR/xpath#dt-expanded-namehttp://www.w3.org/TR/xpath#dt-expanded-namehttp://www.w3.org/TR/xslt#result-element-stylesheet%23result-element-stylesheethttp://www.w3.org/TR/xslt#result-element-stylesheet%23result-element-stylesheethttp://www.w3.org/TR/xslt#result-element-stylesheet%23result-element-stylesheethttp://www.w3.org/TR/xslt#result-element-stylesheet%23result-element-stylesheethttp://www.w3.org/TR/xslt#result-element-stylesheet%23result-element-stylesheethttp://www.w3.org/TR/xslt#dt-top-level%23dt-top-levelhttp://www.w3.org/TR/xslt#dt-top-level%23dt-top-levelhttp://www.w3.org/TR/xslt#fallback%23fallbackhttp://www.w3.org/TR/xslt#fallback%23fallbackhttp://www.w3.org/TR/xslt#fallback%23fallbackhttp://www.w3.org/TR/xslt#fallback%23fallbackhttp://www.w3.org/TR/xslt#named-templates%23named-templateshttp://www.w3.org/TR/xslt#named-templates%23named-templateshttp://www.w3.org/TR/xslt#modes%23modeshttp://www.w3.org/TR/xslt#attribute-sets%23attribute-setshttp://www.w3.org/TR/xslt#key%23keyhttp://www.w3.org/TR/xslt#format-number%23format-numberhttp://www.w3.org/TR/xslt#variables%23variableshttp://www.w3.org/TR/REC-xml-names#NT-QNamehttp://www.w3.org/TR/xpath#dt-expanded-namehttp://www.w3.org/TR/xslt#result-element-stylesheet%23result-element-stylesheethttp://www.w3.org/TR/xslt#result-element-stylesheet%23result-element-stylesheethttp://www.w3.org/TR/xslt#dt-top-level%23dt-top-levelhttp://www.w3.org/TR/xslt#fallback%23fallback
  • 8/14/2019 WE Expriment Manual1

    36/40

    XSLT 1.1 required

    Sorry, this stylesheet requires XSLT 1.1.

    NOTE:If a stylesheet depends crucially on a top-level element introduced by a version ofXSL after 1.0, then the stylesheet can use an xsl:message element with terminate="yes"

    (see [13 Messages]) to ensure that XSLT processors implementing earlier versions of

    XSL will not silently ignore the top-level element. For example,

    Sorry, this stylesheet requires XSLT 1.1.

    ...

    ...

    If an expression occurs in an attribute that is processed in forwards-compatible mode,then an XSLT processor must recover from errors in the expression as follows:

    if the expression does not match the syntax allowed by the XPath grammar, then

    an error must not be signaled unless the expression is actually evaluated;

    if the expression calls a function with an unprefixed name that is not part of theXSLT library, then an error must not be signaled unless the function is actually

    called;

    http://www.w3.org/TR/xslt#message%23messagehttp://www.w3.org/TR/xslt#message%23messagehttp://www.w3.org/TR/xslt#message%23messagehttp://www.w3.org/TR/xslt#message%23messagehttp://www.w3.org/TR/xslt#dt-expression%23dt-expressionhttp://www.w3.org/TR/xslt#message%23messagehttp://www.w3.org/TR/xslt#dt-expression%23dt-expression
  • 8/14/2019 WE Expriment Manual1

    37/40

    if the expression calls a function with a number of arguments that XSLT does not

    allow or with arguments of types that XSLT does not allow, then an error must

    not be signaled unless the function is actually called.

    2.6 Combining Stylesheets

    XSLT provides two mechanisms to combine stylesheets:

    an inclusion mechanism that allows stylesheets to be combined without changing

    the semantics of the stylesheets being combined, and

    an import mechanism that allows stylesheets to override each other.

    2.6.1 Stylesheet Inclusion

    An XSLT stylesheet may include another XSLT stylesheet using an xsl:include element.

    The xsl:include element has an href attribute whose value is a URI reference identifyingthe stylesheet to be included. A relative URI is resolved relative to the base URI of the

    xsl:include element (see [3.2 Base URI]).

    The xsl:include element is only allowed as a top-level element.

    The inclusion works at the XML tree level. The resource located by the href attributevalue is parsed as an XML document, and the children of the xsl:stylesheet element in

    this document replace the xsl:include element in the including document. The fact thattemplate rules or definitions are included does not affect the way they are processed.

    The included stylesheet may use the simplified syntax described in [2.3 Literal Result

    Element as Stylesheet]. The included stylesheet is treated the same as the equivalent

    xsl:stylesheet element.

    It is an error if a stylesheet directly or indirectly includes itself.

    NOTE:Including a stylesheet multiple times can cause errors because of duplicate

    definitions. Such multiple inclusions are less obvious when they are indirect. For

    example, if stylesheetB includes stylesheetA, stylesheet Cincludes stylesheetA, andstylesheetD includes both stylesheetB and stylesheet C, thenA will be included

    indirectly byD twice. If all ofB, CandD are used as independent stylesheets, then theerror can be avoided by separating everything inB other than the inclusion ofA into a

    separate stylesheetB'and changingB to contain just inclusions ofB'andA, similarly forC, and then changingD to includeA,B', C'.

    http://www.w3.org/TR/xslt#base-uri%23base-urihttp://www.w3.org/TR/xslt#base-uri%23base-urihttp://www.w3.org/TR/xslt#base-uri%23base-urihttp://www.w3.org/TR/xslt#base-uri%23base-urihttp://www.w3.org/TR/xslt#dt-top-level%23dt-top-levelhttp://www.w3.org/TR/xslt#result-element-stylesheet%23result-element-stylesheethttp://www.w3.org/TR/xslt#result-element-stylesheet%23result-element-stylesheethttp://www.w3.org/TR/xslt#result-element-stylesheet%23result-element-stylesheethttp://www.w3.org/TR/xslt#result-element-stylesheet%23result-element-stylesheethttp://www.w3.org/TR/xslt#result-element-stylesheet%23result-element-stylesheethttp://www.w3.org/TR/xslt#base-uri%23base-urihttp://www.w3.org/TR/xslt#dt-top-level%23dt-top-levelhttp://www.w3.org/TR/xslt#result-element-stylesheet%23result-element-stylesheethttp://www.w3.org/TR/xslt#result-element-stylesheet%23result-element-stylesheet
  • 8/14/2019 WE Expriment Manual1

    38/40

    2.6.2 Stylesheet Import

    An XSLT stylesheet may import another XSLT stylesheet using an xsl:import element.Importing a stylesheet is the same as including it (see [2.6.1 Stylesheet Inclusion])except that definitions and template rules in the importing stylesheet take precedence

    over template rules and definitions in the imported stylesheet; this is described in more

    detail below. The xsl:import element has an href attribute whose value is a URI reference

    identifying the stylesheet to be imported. A relative URI is resolved relative to the baseURI of the xsl:import element (see [3.2 Base URI]).

    The xsl:import element is only allowed as atop-levelelement. The xsl:import element

    children must precede all other element children of an xsl:stylesheet element, includingany xsl:include element children. When xsl:include is used to include a stylesheet, any

    xsl:import elements in the included document are moved up in the including document toafter any existing xsl:import elements in the including document.

    For example,

    italic

    The xsl:stylesheet elements encountered during processing of a stylesheet that contains

    xsl:import elements are treated as forming an import tree. In the import tree, each

    xsl:stylesheet element has one import child for each xsl:import element that it contains.Any xsl:include elements are resolved before constructing the import tree. An

    xsl:stylesheet element in the import tree is defined to have lowerimport precedencethan another xsl:stylesheet element in the import tree if it would be visited before thatxsl:stylesheet element in a post-order traversal of the import tree (i.e. a traversal of the

    import tree in which an xsl:stylesheet element is visited after its import children). Each

    definition and template rule has import precedence determined by the xsl:stylesheetelement that contains it.

    For example, suppose

    stylesheetA imports stylesheetsB and Cin that order;

    stylesheetB imports stylesheetD;

    stylesheet Cimports stylesheetE.

    http://www.w3.org/TR/xslt#include%23includehttp://www.w3.org/TR/xslt#include%23includehttp://www.w3.org/TR/xslt#include%23includehttp://www.w3.org/TR/xslt#include%23includehttp://www.w3.org/TR/xslt#base-uri%23base-urihttp://www.w3.org/TR/xslt#base-uri%23base-urihttp://www.w3.org/TR/xslt#base-uri%23base-urihttp://www.w3.org/TR/xslt#base-uri%23base-urihttp://www.w3.org/TR/xslt#dt-top-level%23dt-top-levelhttp://www.w3.org/TR/xslt#dt-top-level%23dt-top-levelhttp://www.w3.org/TR/xslt#dt-top-level%23dt-top-levelhttp://www.w3.org/TR/xslt#include%23includehttp://www.w3.org/TR/xslt#base-uri%23base-urihttp://www.w3.org/TR/xslt#dt-top-level%23dt-top-level
  • 8/14/2019 WE Expriment Manual1

    39/40

    Then the order of import precedence (lowest first) isD,B,E, C,A.

    NOTE:Since xsl:import elements are required to occur before any definitions or template

    rules, an implementation that processes imported stylesheets at the point at which itencounters the xsl:import element will encounter definitions and template rules in

    increasing order of import precedence.

    In general, a definition or template rule with higher import precedence takes precedence

    over a definition or template rule with lower import precedence. This is defined in detailfor each kind of definition and for template rules.

    It is an error if a stylesheet directly or indirectly imports itself. Apart from this, the case

    where a stylesheet with a particular URI is imported in multiple places is not treated

    specially. The import treewill have a separate xsl:stylesheet for each place that it isimported.

    NOTE:If xsl:apply-imports is used (see [5.6 Overriding Template Rules]), the behaviormay be different from the behavior if the stylesheet had been imported only at the place

    with the highest import precedence.

    Embedding Stylesheets

    Normally an XSLT stylesheet is a complete XML document with the xsl:stylesheet

    element as the document element. However, an XSLT stylesheet may also be embeddedin another resource. Two forms of embedding are possible:

    the XSLT stylesheet may be textually embedded in a non-XML resource, or

    the xsl:stylesheet element may occur in an XML document other than as thedocument element.

    To facilitate the second form of embedding, the xsl:stylesheet element is allowed to have

    an ID attribute that specifies a unique identifier.

    NOTE:In order for such an attribute to be used with the XPath idfunction, it must

    actually be declared in the DTD as being an ID.

    The following example shows how the xml-stylesheet processing instruction [XMLStylesheet]can be used to allow a document to contain its own stylesheet. The URI

    reference uses a relative URI with a fragment identifier to locate the xsl:stylesheetelement:

  • 8/14/2019 WE Expriment Manual1

    40/40

    version="1.0"

    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

    xmlns:fo="http://www.w3.org/1999/XSL/Format">

    ...

    Thus, we studied XSL