Professional Documents
Culture Documents
Notations
HTML:HYPER TEXT MARKUP LANGUAGE
RE:REQUIREMENTE ENGINEERING
1.1 Motivation
Defining Web Applications
• Unlike traditional software, the Web serves as both development &
user platform.
• A Web application is a system that utilizes W3C standards &
technologies to deliver Web-specific resources to clients (typically)
through a browser.
– Kind of …
• Technology + interaction.
– Web site with no software components?
– Web services?
The strong interlinking of web applications additionally increases the
danger of problems spreading from one application to other. The
reasons for this situation are complex:
• Document centric approach: The development of web
applications is often still considered to be document centric
i.e.,an authoring activity that includes the creation and linking of
web sites and the inclusion of graphics.Applications such as(e.g.
homepage ,online news paper etc)fall in this category,such
viewpoint is not adequate for the development of software
intensive web applications.
• The assumed simplicity of web applications development:
Availability of HTML editors makes application simple .Usually the
emphasis is on visual design rather than internal structuring and
programming. This results in inconsistencies and redundancy.
• Know-how from relevant disciplines cannot be applied or is not
used: It is common misconception that the development of web
applications is analogus to the development of traditional
applications and that therefore the methods of software
engineering can be used in the sense of a systematic disciplined
approach with adequate quality control measures.
Portal-Oriented
• Single points-of-entry to heterogeneous information
– Yahoo!, AOL.com, my.pitt.edu
• Specialized portals
– e g Business portals (e.g., employee intranet)
– Marketplace portals (horizontal & vertical)
– Community portals (targeted groups)
Ubiquitous
• Customized services delivered anywhere via multiple devices
• HCI is critical
– Limitations of devices (screen size, bandwidth?)
– Context of use
• Still an emerging field; most devices have single focus:
– Personalization
– Location-aware
– Multi-platform delivery
Semantic Web
• Berners-Lee: Information on the Web should be readable to
machines, as well as humans.
• Using metadata and ontologies to facilitate knowledge management
across the WWW.
• Content syndication (RSS, Atom) promotes re-use of knowledge
• Is the Semantic Web even possible?
• Authors devote a chapter to the Semantic Web, but we will not focus
on it in this course.
1.3 Characteristics of Web Apps
• How do Web applications differ from traditional applications?
• Or, another way, what Software Engineering methods & techniques
can be adapted to Web Engineering?
• 3 dimensions of the ISO/IEC 9126-1 standard
– Product
– Usage
– Development
• To this we can add a 4th dimension peculiar on the web, need for
continuous and fast evolution!
Flowchart of Characteristics of Web Applications
USE
Technical
contextContext Physic
Social al
Contex contex
t PRODUCT t
Presentation Contex
Hypertext t
Project Content
Integratio
team nnnnnn
Team
Technical
infractureInfrastruct
ure
DEVELOPMENT
Characteristics - Product
• The “building blocks” of a Web application
• Content
– Document character & multimedia (# of dimensions?)
– Quality demands
• Navigation Structure (Hypertext)
– Non-linearity
Social
Context
– Disorientation & cognitive overload
• User interface (Presentation)
– Aesthetics
Developmen
Team
Develop
Proc
– Self-explanation
Characteristics - Usage
• Much greater diversity compared to traditional non-Web applications
• Social Context (Users)
– Spontaneity
– Heterogeneous groups
• Technical Context (Network & Devices)
– Quality-of-Service
– Multi-platform delivery
• Natural Context (Place & Time)
– Globality
– Availability
eb Engineering (703512)
Characteristics - Development
• The Development Team
– Multidisciplinary
– Community (including Open Source)
• Technical Infrastructure
– Lack of control on the client side
– Immaturity
• Process
– Flexibility
– Parallelism
• Integration
– Internal
– External
Mandatory reading(learning)
– Web Engineering(Kappel)
• Chapter 1
Self learning
• Suggggested
– Google “Web Engineering”
– (link to localization http://www.w3.org/2006/07/MWI-EC/Presentation/cdac.ppt)
CHAP 2 REQUIREMENT ENGINEERING OF WEB APPLICATION
Notations
RE:REQUIREMENTS ENGINEERING
Background
When the “Software Crisis”1 was discovered and named in the 1960s,
much effort was directed at finding the causes of the now-familiar
syndrome of problems. The investigations determined that
requirements deficiencies are among the most important contributors
to the problem: “In nearly every software project which fails to meet
performance and cost goals, requirements inadequacies play a major
and expensive role in project failure.” 2 Development of the
requirements specification “in many cases seems trivial, but it is
probably the part of the process which leads to more failures than any
other.” It was determined that the benefits of good requirements
include:
· Agreement among developers, customers, and users on the job to be
done and the acceptance criteria for the delivered system
· A sound basis for resource estimation (cost, personnel quantity and
skills, equipment, and time)
· Improved system usability, maintainability, and other quality
attributes
· The achievement of goals with minimum resources (less rework,
fewer omissions and misunderstandings)
Iteration in partitioning, allocation, and flowdown
The process of partitioning, allocation, and flowdown is then repeated to as low a level as
needed for this particular system; for software elements this is often to the module level.
Figure 9 emphasizes the iterative nature of this process at each level in the many levels of
partitioning, allocation, and flowdown.
Overview
• Introduction to Requirements Engineering
– Principles
– Adapting traditional Requirements Engineering to Web applications
– Specifics in Web Engineering
• Elicitation & Negotiation
• Specification
• Validation and Management
• Example
Why do we need Web Engineering?
2.1 INTRODUCTION
Requirements play a key role in the development of web
applications.However ,requirements are often not described properly
and may be specific in an ambiguous ,vague, or incorrect manner.
Typical consequences of poor requirement are low user acceptance ,
planning failures ,or inadequate software architectures.
• Requirements Engineering (RE) – the principles, methods & tools for
eliciting methods, eliciting, describing, validating, and managing
project goals and needs.
• Given the complexity of Web apps, RE is a critical initial stage, but
often poorly executed.
• What are the consequences?
– Inadequate software architectures
– “Unforeseen” problems
• Budget overruns
• Production delays
• “That’s not what I asked for”
– Low user acceptance
What is a Requirement?
• A requirement describes a property to be met or a service to be
provided by a system.
• IEEE 601.12 definition of requirement:
1. Condition needed to solve a user’s problem
2. Condition to be met or possessed by the system to satisfy a formal
agreement
3. Documented representation of conditions as in 1 and 2
• Key players in the game
– Contract
– Customer
– Supplier
- User
Types of Requirements
• Many taxonomies exist to describe requirements, but most divide
them into two groups:
– Functional – describes the capability’s purpose
• e.g., the ability to transfer money between user accounts
– Non-functional – describes the capability’s properties
• e.g., the Home Page must load within 5 seconds on a dial-up
connection
VALIDATION AND
MANAGEMENT
Validation
• This step is essential to verify that requirements specification
corresponds to user’s needs and customer’s requirements
• Iterative feedback from stakeholders is essential
– Is the requirement feasible?
– Do the results meet stakeholders’ expectations?
• We will discuss testing in greater detail later
Web Engineering (703512) 29
Validation Techniques
• Review or walk-through
– Reading and correcting the requirements definition documentation
and models
• Audit
– Partial check of the results presented in the review documentation
• Traceability Matrix
– Comparison of the application objectives with the requirements of the
system
• Prototyping for Validation
– Implement a partial set of functional requirements but provide a
global vision of the user interface
Management
• Several tools are available to support Requirements
( management also Open Source)
– http://www.paper-review.com/tools/rms/read.php
• Tool support is crucial for big project
• Enable
– Traceability
– Modifiability
– Verifiability
EXAMPLE
Requirement analysis
• Revision and formalization of the collected requirements, producing
in output a set of semiformal specifications, typically in terms of:
I. Group specification
II. Use-case specification
III.Data dictionary specification
IV.Site view specification
V. Style guidelines specification
VI.Acceptance tests specification
I. Group specification
• Clustering of users into groups (formally described)
) 38
V. Style guidelines specification
Rules for the presentation of pages:
• Specification of standard page grids: rows, columns and cells
arrangement
• Content positioning specification: banners, logo, menus positioning
• Graphical guidelines: rules for graphic items like fonts, colors,
borders and margins
• Device-specific and browser-specific guidelines
• Example: Mock-ups: sample representations of a few typical
application pages for a specific device and rendition language)
W) 40
V. Style guidelines specification
Notations
W3C:WORLD WIDE WEB CONSRTIUM
HTTP:HYPERTEXT TRANSFER PROTOCOL
HTML:HYPERTEXT MARKUP LANGUAGE
Overview
• Introduction
• HTML & XHTML
• CSS
• JavaScript
Chap 3 Technologies for Web Applications
What are the basic ingredients to start to build a Web site
INTRODUCTION
Basic Ingredients
Content structuring (and “basic” presentation…)
– (X)HTML
• Business logic (client side)
– JavaScript
• Presentation
– CSS
• … with these 3 elements you can start building nice (content static)
interfaces for you web applications
• HTML Advantages
– Platform Portability
– Speed (size of file)
– Text File
HTML Disadvantages
– Rendering Differences
– Extensions
• Proprietary Functionality Added by Browsers
XHTML Advantages
– Resolve Issues with Different HTML Versions
Syntax
• Elements (Tags)
– Codes that Control Content Appearance
– Opening/Closing
• Two-Sided
– <tagName>Content</tagName>
• One-Sided
– <tagName />
– Lowercase
• Deprecated
– Obsolete Elements or Syntax
– Future Support Not Guaranteed
• Comments
– <!-- . . . -->
• <!-- This is a comment. -->
• White Space
– Does Not Render Multiple Spaces
– Tab, Enter do not Render
– Use Non-breaking Space
•
• Attributes
– Controls Behavior or Appearance of Element
• <tagName attrib#1=“Value” attrib#2=“Value” />
<html>
• <html>…</html>
– Surround All Markup & Text
– Required
– Used To Begin & End Every g y HTML Document
<head>
• <head>…</head>
– Contains the Document's Header Information
– Required
– Important Information
• Document Title
• META Tags
– Text Included Does Not Render
<body>
• <body>…</body>
– Contains All Content to be Rendered
• Attributes
– leftmargin=number
• Sets The Left Margin for Page
– topmargin=number
• Sets the Top Margin for the Page
• Styles
– style=“color: colorName | #rrggbb | rgb(#,#,#);”
• Specifies the Color of the Regular Text
– style=“background-color: colorName | #rrggbb | rgb(#,#,#);”
• Specifies the Background Color
– style=“background-image: url(filename.ext);”
• Points to Location of Image that is Used as Background
• Image is Tiled
• Styles
– style=“background-position: horizontal vertical;”
• Specifies the Positioning of the Background Image
• Can Specify Keywords or Percentages
– style=“background-repeat: repeat | repeat-x | repeat-y | norepeat;”
• Specifies the Tiling of the Background Image
– style=“background-attachment: scroll | fixed;”
• Background Image Scrolls with Page or Acts as Watermark
<h#>
• <h#>…</h#>
– Create a Heading
– Numbered from h1 through h6
• h1 is the Top Head Level While h6 is the Bottom
– Should not be Used for Text Formatting
– Convey Page & Content Organization
– Should be Used in Descending Order
• Style
– style=“text-align: left | center | right | justify;”
• Specifies the Alignment of the Heading Text
Lists
• <ul>…</ul>
– Unordered List Renders a Bulleted List
– Use Where Order or Rank is Unimportant
• Style
– style=“list-style-type: disc | square | circle;”
• Changes Style of Bullet Before Item
– style=“list-style-image: url(filename.ext);”
• Image Used as Bullet
• <ol>…</ol>
– Ordered List Tags Render a Numbered List
• Style
– style=“list-style-upper-upper-style list style type: decimal | upper
roman | upper alpha |
. . .;”
• Changes Number / Letter Style Before Item
– style=“list-style-position: inside | outside;”
• Changes Wrapped Item Placement
• <li>…</li>
– Defines an Item in a List
• <dl>…</dl>
– Definition List
– <dt>…</dt>
• Defined Term
– <dd>…</dd>
• Definition
<img>
• <img />
– Inserts an Image Into a Document
– Secondary to Content
• Attributes
– alt=“text”
• Provides Alternative Text that Describes the Image
• IE Displays ALT Text When User Hovers on Image
– Users Who Surf With Graphics Turned Off
– Non-graphical Browsers
» Alt Text is Displayed in Place of Image
• Required
• Attributes
– height=“pixels”
• Specifies the Image's Height
– src=“URL”
• Specifies Location of Image to Place in Web Page
• Required
– width=“pixels”
• Specifies the Image's Width
• Style
– style=“float: none | left | right;”
• Place Image on Left / Right & Wrap Text Around It
– style=“clear: none | left | right;”
• Display Content After Margin is Clear of Floating Elements
– style=“margin: top# right# bottom# left#;”
– style=“yle=“border-width: #;”
• Rendered in Designated Link Color if Image is a Link
<hr>
• <hr />
– Inserts Plain Line (Horizontal Rule) Across Page
– Emphasize Divisions & Transitions In Content
• Style
– style=“background-color: #RRGGBB | colorname;”
– style=“color: #RRGGBB | colorname;”
– style=“height: number;”
– style=“width: number;”
Special Characters
• &
– Ampersand
• ©
– Copyright
• ·
– Bullet
• ®
– Registered
• ™
– Trademark
<a>
• <a>…</a>
– Used to Create Links to Other Resources
– Named Anchor
• AKA Bookmark
• Used to Name Specific Locations within a Page
• id Attribute
– Defines Destination
Web Engineering (703512) 30
• Attributes
– accesskey=“text”
• Character Used as Keyboard Shortcut to Activate Link
– coords=“X1, Y1, X2, Y2, etc.”
• Coordinates that Define Hot Spot Shape in Image Map
– href=“URL”
• Specifies Location of Linked Resource
– Typically Another HTML File
– Can Also Specify Other Internet Resources
» Files, E-mail, FTP
• Named Anchor or Bookmark URLs are Preceded By #
• Attributes
– name=“text”
• Marks Specific Place Within an HTML Document
• AKA Named Anchor or Bookmark
– rel=“text”
• Indicates Relationship Between Documents
– rel=“stylesheet”
» Tells that Browser Linked Document is a Style Sheet
– shape=“rect | circle | poly | default”
• Specifies Shape of Hot Spot in Image Map
• Attributes
– title=“text”
• Provides Supplemental Information Regarding a Link
– Behaves Like a Tooltip
Should be – Less Than 60 Characters
• Example
<a href="http://www.mysite.com/">A link to a
site.</a>
< a href="#P5">A link to paragraph 5 in same
document.</a>
<p>Paragraph 1</p>
<p>Paragraph 2</p>
<p>Paragraph 3</p>
<p>Paragraph 4</p>
<p id=“P5”>Paragraph 5 content.</p>
Paths
• URL (Uniform Resource Locator)
– Location of Document on Web
• www.
• Path
– Location of Document on Server
• http://www. /about/team/details/
• Absolute
– Exact Location on Server
• Begins with a /
– /student/index.htm
• Relative
– Location Relative to Current Document
• Current — Nothing
– page.htm
• Child — Separated by /
– images/background.gif
• Parent — Two Periods (..)
– ../page.htm
Web Engineering (703512) 36
URL
• http://www. /about/team/details.html
– Communication Protocol
• http://
– Domain
• www.
– Path
• /about/team/
– Document
• details.html
Protocols
• Hypertext Transfer Protocol
– Web Server
– http://
• File Transfer Protocol
– File Server
– ftp://
• USENET
– Newsgroup
– <a href=“news:newsgroup.name”>Click Me</a>
• E-Mail
– Mailto
• <a href=“mailto: priyanka.desai@thakureducation.org”>Send
Mail</a>
– Can Automatically Include Subject Line
• “mailto: priyanka.desai@thakureducation.org?subject=text”
– Other Options
• “mailto: priyanka.desai@thakureducation.org?cc=another@sti2.at
bcc=secret@cod.edu&subject=subscribe
&body=Send me your newsletter right away”
<table>
• <table>…</table>
– Structure to Control Page Layout
– Structure to Contain & Align Content
• Attributes
– border=“#”
• Sets Thickness of Borders Displayed for Table Cells
• Attribute Set to 0 Will Make Borders “Invisible”
• Attributes
– cellpadding=“#”
• Specifies Amount of Space Between Cell & Content in Cell
– cellspacing=“#”
• Specifies Amount of Space Between Cells
– frame=“above | below | border | box | hsides | lhs | rhs |
void | vsides”
• Specifies Where Borders of Tables & Cells Appear
• Attributes
– height=“# | %”
• Specifies Height of Table in Pixels or Percentage of Window
– rules=“all | cols | groups | none | rows”
• Specifies Where Gridlines Appear in a Table
– valign=“top | bottom | middle ”
• Specifies Vertical Alignment of Text in Cells
– width=“# | %”
• Specifies Width of Table in Pixels or Percentage of Window
<colgroup>
• <colgroup>…</colgroup>
– Defines Groups of Table Columns for Formatting
– Only Valid Inside <table>
• Attributes
– align=“left | center | right | justify | char”
• Specifies Horizontal Alignment of Contents in Column Group
– char=“character”
• Specifies Character to Use to Align Text On
• Attributes
– span=“#”
• Specifies Number of Columns <colgroup> Should Span
– valign=“top | middle | bottom | baseline”
• Specifies Vertical Alignment of Contents in <colgroup>
– width=“# | %”
• Specifies Width of Each Column in <colgroup>
• 0* - Column Width Should be Minimum Width
W
<col>
• <col />
– Defines One or More Columns of Table for Formatting
– Only Valid Inside <table> or <colgroup>
• Attributes
– align=“left | center | right | justify | char”
• Specifies Horizontal Alignment of Contents in Table Column
– char=“character”
• Specifies Character to Use to Align Text On
• Attributes
– span=“#”
• Specifies Number of Columns the Column Should Span
– valign=“top | middle | bottom | baseline”
• Specifies Vertical Alignment of Contents in Table Column
– width=“# | %”
• Specifies Width of Column
• 0* - Column Width Should be Minimum Width
<td>
• Attributes
– colspan=“#”
• Specifies How Many Columns the Cell Overlaps
– rowspan=“#”
• Specifies How Many Rows the Cell Overlaps
CSS Basics
• Style Rules
– Determines Style Characteristics for an HTML Element
– Selector
• Determines Element to Which Rule is Applied
– Declaration
• Details the Exact Property Values
– Property
Quality or Characteristic » Quality (e.g., Color)
– Value
» Specification of Property (e.g., Blue)
• Style Sheet
– Set of Style Rules
• Style Rule Syntax
Combining
CSS & HTML
• Inline
– Modify the Appearance of a Particular Element
• Style Attribute
• Embedded
– Applied To An Entire Document
• Redefines All Occurrences of a Particular Element
– Uses <style>…</style> in <head>
• Linked
– External File of Declarations Available to an Entire Site
• ASCII File with an Extension of .css
Inline Style
• Defines a Style for a Single Element
– Generally Used to Override a Style Set at a Higher Level
– Only Affects One Instance of an Element
• Syntax
< tag style=“property:value1; property:value2;”>
<h1 style=“color:green; font-family:sans-serif;”>
<b style=“color:yellow; background-color:green;”>
Embedded Style
• Always Contained in the <head>
– Generally Used to Override a Style Set at a Higher Level
– Only Affects the Document in which it Resides
• Syntax
– selector {declarations}
<style type=“text/css”>
h1 {color:green; font-family:sans-serif;}
b {color:yellow; background-color:green;}
</style>
Web Engineering (703512) 54 Linked StyleLinked Style
Linked Style
• External Style Sheet
– Always Contained in the <head>
– Text Document that Contains Style Rules
– Allows Specification of Rules for Multiple Documents
– Does Not Contain HTML Code
• Syntax
• <link rel=“stylesheet” href=“master.css” />
Cascading
• Determines Which Rules are Assigned to Elements
• Weight Assignment Based on Four Variables:
– Use of the !Important Keyword
– Origin of the Rule
– Specificity of the Selector
– Order of the Rule in the Style Sheet
• Rule Weight with the !Important Keyword
– Allows User to Override Author’s Style Setting
• For Particular Element
– Improves Accessibility p y of Documents
• Gives Control to Users with Special Requirements
• Rule Weight by Origin
– Cascading Order of Precedence:
1. Rules From Author’s Style Sheet
2. Rules From User’s Style Sheet
3. Rules From Browser’s Style Sheet
• Rule Weight by Specificity
– Rules with More Specific Selectors Take Precedence Over
Rules with Less Specific Selectors
• Rule Weight by g y Order
– Based on Order of Rule within Style Sheet
• Rules Listed Later Take Precedence Over Those Listed Earlier
gineering (703512
Inheritance
• Parent
– Element that Contains Another Element
• Child
– Element within Another Element
• Inheritance
– CSS Rules Inherit from Parent to Child Elements
• Based on Hierarchical Structure of Documents
Basic Selection
• Type Selectors
– Selector Determines Element to which Declaration is
Applied
– Style Sheet Examples:
• h2 {color: red;}
• p {font-size: 10 pt;}
• Grouping Selectors
– Set the Same Declaration for Multiple Selectors
• Syntax:
• h1 {color: red;}
• h2 {color: red;}
or
• h1, h2 {color: red;}
• Combining Declarations
– Multiple Declarations May be Stated for Same Selector
• Syntax:
• p {color: blue;}
• p {font-size: 12pt;}
or
• p {color: blue; font-size: 12pt;}
• Descendant Selector
– AKA Contextual Selectors
– Based on Hierarchical Structure of Elements in Document
• Syntax:
– b i {color: #336699; background-color: #000000;}
– Does Not Apply to i b
W
eb Engineering (703512) 66
Advanced Selection
• idAttribute Selector
• Syntax:
<p class=“quote”>Text in red with a 30 pixel margin</p>
– May be Restricted to a Specific Element Type
h1.quote {color: red; margin: 30px;}
• <div>…</div>
– Block Level Element
– Used to Contain Other HTML Elements
– Displayed Discretely p y y from the Rest of the Document
• Paragraph Breaks Added Before and After <div> Contents
• <span>…</span>
– Inline Element
– Used to Contain Other HTML Elements
– Used within Text Blocks
• Pseudo-Class Selectors
– Select Elements Based on Characteristics Other Than
Name
– Link Pseudo-Classes
• :link
– Allow Modification of Style Characteristics for Unvisited Links
:link {color: green;}
• :visited
– Allow Modification of Style Characteristics for Visited Links
:visited {color: green;}
• Pseudo-Class Selectors
– Dynamic Pseudo-Classes
• Apply Styles to an Element Based on User’s Actions
• :hover
– Applies Style When User Mouses Over Element
• :active
– Applies Style When User Activates Element
• :focus
– Applies Style When Element is Accepting User Input
eb Engineering (703512) 25
• Pseudo-Elements Selectors
– Modify Aspects of Document Not Classified by Elements
– :first-letter
• Apply Style Rules to the First Letter of Any Block-level Element
– Initial Capitals
– Drop Capitals
• Pseudo-Element Selectors
– :first-letter
• Pseudo-Element Selectors
– :first-line
• Apply Style Rules to the First Line of Any Block-level Element
• Child Selector
–>
• Apply Style Rules to Child Elements of Any Parent
div > blockquote {font-weight: bold;}
• First Child
– :first-child
• Apply Style Rules to the First Child Element of a Parent
div > p:first-child {font-weight: bold;}
• Adjacent Sibling
• Apply Style Rules to
– Elements that Share the Same Parent
Are Adjacent in – the Code
Fonts
• Measurement Units
– Absolute Units
• Specify a Fixed Value
• Cannot be Scaled to Client Display
– Use Only When Measurements of User Medium are Known
– Relative Units
• Enables Scalable Web Pages
– Adapt to Different Display Types & Sizes
– Recommended Method for Web Page Design
• Measurement Units
Font Properties
• Styles
– style=“font-family: fonts;”
• Allows Specification of Font Family Names
• Generic Font Families
– Allows Greater Portability Across Platforms
– Serif → Traditional Letter Form (e.g., Times)
– Sans-serif → Block Letters, Have no Serifs (e.g., Arial)
– Monospace → Fixed-width
» Every Letter has Same Horizontal Width
– Cursive → Resembles Handwriting (Limited Support)
– Fantasy → Primarily Decorative (Limited Support)
• Styles
– style=“font-family: fonts;”
• Specific Font Families
– Allows Specification of Particular Font-family
» Garamond, Impact
– User Must Have Font Installed on Machine
» If not, Browser Will Supply Default
• Example:
<p style=“font-family: arial;”>eb Engineering (703512) 81
• Styles
– style=“font-family: fonts;”
• Specifying Font Substitution
– Allows Specification of Alternate Fonts
» Uses Comma Separated List
– Browser Scans List for First Installed Font
» Otherwise, Browser Supplies Default
– Generic Font-family Names can be Used
• Example:
<p style=“font-family: verdana,arial,helvetica,sans-serif;”>
• Styles
• Styles
– style=“font-style: normal | italic | oblique;”
– style=“font-variant: normal | small-caps;”
– style=“font-weight: normal | bold bolder lighter y g | | g | #;”
• # = 100 – 900 in Increments of 100
• 400 = Normal
• 700 = Bold
• Font Shortcut
– Allows Specification of Properties in a Single Statement
– Font-size & Font-family Required
• Must be in Order
– Line-height Must be Preceded by /
• Example:
<p style=“– style= font: 18pt/24pt arial bold;”>
Web Engineering (703512) 86
Text Properties
• Styles
– style=“line-height: # | %;”
• AKA Leading
– style=“letter-spacing:
normal | #;”
• AKA Kerning
– style=“word-spacing:
normal | #;”
• AKA Tracking
• Styles
style=“text-decoration: none underline | overline | linethrough
| blink;”
– style=“text-transform: capitalize | uppercase | lowercase |none;”
• Styles
style=“vertical-align: baseline | sub | super | top | texttop
| middle | bottom | text-bottom | % | #;”
Margin Properties
• margin: # | %
-Shorthand Property Sets All Four Individual Margins
Padding Properties
• padding: # | %
– Shorthand Property Sets All Four Individual Paddings
• Same Format as Margin
• padding-left | padding-right | padding-top |
padding-bottom: # | %
Border Properties
• border: style width color
– Shorthand Property Sets All Four Individual Borders
• Same Format as Margin
• border-style: keyword
–Keywords
• none
• dotted
• dashed
• solid
• double
• groove
• ridge
• inset
• outset
• border-width: thin | medium | thick | #
• border-color: value
Special Box Properties
• width: # | %
– Sets Horizontal Width of a Containing Box
• height: # | %
– Sets Vertical Height of a Containing Box
• float: left | right ght | none
– Sets Position of an Element to Left/Right of Parent Element
• clear: none | left | right | both
– Controls Flow of Text Around Floated Elements
• float & clear
Background Properties
• background-color: colorname | #
• background-image: url(imagename.gif)
• background-repeat: repeat | repeat-x | repeat-y |no-repeat
List Properties
• list-style-type: disc | circle | square | decimal |
decimal leading lower decimal-leading-zero | lower-roman | upper-
roman |
lower-greek | lower alpha | lower-latin | upper-alpha
| upper-latin | hebrew | armenian | georgian | cjkideographic
| hiragana | katakana | hira-ganairoha |
katakana-iroha | none
– Default = disc
– Allows Customization of the List Marker
• Syntax:
ul {list-style-type: circle;}
• list-style-type
• list-style-image: url(filename.ext)
– Allows Use of Image as List Marker
• Syntax:
ul {list-style-image: url(paw.gif);}
Language Basics
• JavaScript is case sensitive
– onClick, ONCLICK, … are HTML, thus not case-sensitive
• Statements terminated by returns or semi-colons
– x = x+1; sameas same as x = x+1
• “Blocks” of statements enclosed in { …}
• Variables
– Define using the var statement
– Define implicitly by its first use, which must be an
assignment
• Implicit defn has global scope, even if occurs in nested scope!
JavaScript Primitive Datatypes
• Boolean: true and false
• Number: 64-bit floating point
– Similar to Java double and Double
– No integer type
– Special values NaN (not a number) and Infinity
• String: sequence of zero or more Unicode chars
– No separate character type (just strings of length 1)
– Literal strings using ' or " characters (must match)
• Special objects: null and undefined
Objects
• An object is a collection of named properties
• Think of it as an associative array or hash table
– Set of name:value pairs
• objBob = { name: “Bob", grade: 'A', j ,g , level: 3};
– Play a role similar to lists in Lisp / Scheme
• New members can be added at any time
• objBob.fullname = 'Robert';
• Can have methods
• Can refer to this
Functions
• Functions are objects with method called “( )”
– A property of an object may be a function (=method)
• function max(x,y) { if (x>y) return x; else return y;};
• max.description = “return the maximum of two arguments”;
– Local declarations may appear in function body
• Call can supply any number of arguments
– functionname.length arguments : # of in definition
– functionname.arguments.length : # arguments in call
– Basic types are passed by value, objects by reference
• “Anonymous” functions
– (function (x,y) {return x+y}) (2,3);
Examples of Functions
• Curried functions
• function CurriedAdd(x) { return function(y){ return x+y} };
• g = CurriedAdd(2);
• g(3)
• Variable number of arguments
function sumAll() {
var total=0;
for (var i=0; i< sumAll.arguments.length; i++)
total+=sumAll.arguments[i];
return(total); }
sumAll(3,5,3,5,3,2,6)
JavaScript eval
• Evaluate string as code
– The eval function evaluates a string of JavaScript code, in
scope of the calling code
var code = "var a = 1";
l( d ) eval(code); // a is now '1‘
var obj = new Object();
obj.eval(code); // obj.a is now 1
Binary Files
• A binary file, at its simplest, is just a stream of bits (1s and 0s).
It’s up to the application that created a binary file to understand
what all of the bits mean. That’s why binary files can only be
read and produced by certain computer programs, which have
been specifically written to understand them.
For example, when a document is created with Microsoft Word,
the program creates a binary file with an extension of “doc,’’ in
its own proprietary format. The programmers who wroteWord
decided to insert certain binary codes into the document to
denote bold text, codes to denote page breaks, and other codes
for all of the information that needs to go into a “doc’’ file. When
you open a document in Word, it interprets those codes and
displays the properly formatted text on-screen or prints it to the
printer.
For example, a word processing document has different meta
data than a spreadsheet document, because they are describing
different things. Not so obviously, documents from different word
processing applications also have different metadata, because
the applications were written differently. (see Figure 1-1).
Text Files
• Like binary files, text files are also streams of bits. However, in a
text file these bits are grouped together in standardized ways, so
that they always form numbers. These numbers are then further
mapped to characters. For example, a text file might contain the
following bits: 1100001 the number 97
• Figure 1-2 shows some of the applications on my machine that
are capable of opening text files. Some of these programs only
allow me to view the text, while others will let me edit it, as well.
So What Is XML?
• I could create an HTML document that displays information about
a person, but that’s about all I could do with the document. I
couldn’t write a program to figure out from that document which
piece of information relates to the person’s first name, for
example, because HTML doesn’t have any facilities to describe
this kind of specialized information. In fact, HTML wouldn’t even
know that the document was about a person at all. Extensible
Markup Language (XML) was created to address these issues.
• Note that it’s spelled “Extensible,” not “eXtensible.” Mixing these
up is a common mistake.
XML is a subset of SGML, with the same goals (markup of any
type of data), but with as much of the complexity eliminated as
possible. XML was designed to be fully compatible with SGML.
• If bandwidth is a critical issue for your applications, you can
always compress your XML documents before sending them
across the network—compressing text files yields very good
results.
HTML file like this:
<html>
<head><title>Name</title></head>
<body>
<p>John Doe</p>
</body>
</html>
Fig-1.4
the out put is as follows
Fig-1.5
Hierarchies in XML
Fig-1.6
<name> is a parent of <first>. <first>, <middle>, and <last> are all
siblings to each other (they are all children of <name>). Note, also,
that the text is a child of the element. For example the text John is a
child of <first>.
XML Parsers
• Parsers are also available for parsing SGML documents, but they
are much more complex than XML parsers. Because XML is a
subset of SGML, it’s easier to write an XML parser than an SGML
parser.
<name>
<first>John</first>
<middle>Fitzgerald Johansen</middle>
<last>Doe</last>
</name>
• The parser can tell us that there is a piece of data called
<middle>, and that the information stored there is Fitzgerald
Johansen. The parser writer didn’t have to know any rules about
where the first name ends and where the middle name begins.
• Just as any HTML document can be displayed by any web
browser, any XML document can be read by any XML
parser, regardless of what application was used to create
it, or even what platform it was created on. This goes a
long way to making your data universally accessible.
• The <p> tag is a predefined HTML tag.
However, web browsers can’t understand the following:
<paragraph>This is a paragraph.</paragraph>
The <paragraph> tag is not a predefined HTML tag.
Question 1
Modify the “name’’ XML document you’ve been working with to include
the person’s title (Mr., Ms., Dr., and so on).
Solution
Because of the self-describing nature of XML, the only hard part about
adding a title to our “name’’ example is deciding what to call it. If we
call it “title,’’we can add it to our document as follows:
<name>
<title>Mr.</title>
<first>John</first>
<middle>Fitzgerald Johansen</middle>
<last>Doe</last>
</name>
Another way to handle it might be to treat a title as a simple prefix to
the name; this would also
allow us the flexibility of adding a suffix. This approach might look like
the following:
<name>
<prefix>Mr.</prefix>
<first>John</first>
<middle>Fitzgerald Johansen</middle>
<last>Doe</last>
<suffix>the 3rd</suffix>
</name>
2.Well-Formed XML
Parsing XML
The main reason for creating all these rules about writing well-formed
XML documents is so that we can create a computer program to read
in the data, and easily tell markup from information.
According to the XML specification (http://www.w3.org/TR/REC-
xml#sec-intro): “A software module called an XML processor is used to
read XML documents and provide access to their content and
structure. It is assumed that an XML processor is doing its work on
behalf of another module, called the application.”
There are quite a number of XML parsers available, many of which are
free. Some of the
better-known ones include:
• Microsoft Internet Explorer Parser—Microsoft’s XML parser,
MSXML, first shipped with Internet Explorer 4, and implemented an
early draft of the XML specification. With the release of IE5, the XML
implementation was upgraded to reflect the XML version 1
specification. The latest version of the parser is available for
download from Microsoft’s MSDN site, at http://msdn.microsoft.com,
and also comes built-in with the Internet Explorer browser.
• Apache Xerces—The Apache Software Foundation’s Xerces
subproject of the Apache XML Project (http://xml.apache.org/) has
resulted in XML parsers in Java and C++, plus a Perl wrapper for the
C++ parser. These tools are free, and the distribution of the code is
controlled by the GNU Public License (GPL).
Since this XML layout will contain information about orders, we need
to capture information like the customer’s name and address, the type
of hardware which has been purchased, information about the
subscription to sernaDirect, and so on.
Figure 2.1 shows the hierarchy we’ll be creating:
save as order.xml
output:
Rules for Elements
XML documents must adhere to certain rules to be well
formed.
We’ll list them, briefly, before getting down to details:
• Every start-tag must have a matching end-tag, or be a self-
closing tag.
• Tags can’t overlap; elements must be properly nested.
• XML documents can have only one root element.
• Element names must obey XML naming conventions.
• XML is case sensitive.
• XML will keep whitespace in your PCDATA.
Elements Must Be Properly Nested
Which can be properly formatted in a tree, like this:
<P>
Some
<STRONG>
formatted
<EM>
text
</EM>
</STRONG>
<EM>
, but
</EM>
no grammar no good!
</P>
XML Declaration
It is often very handy to be able to identify a document as being of a
certain type. On computers running Windows, giving the file an
extension of .xml identifies the file as an XML file to Windows, but on
other operating systems this will not work. Also, we might want the
flexibility of creating XML files with other extensions.
Case Sensitivity
Warning! Because XML is case sensitive, you could legally create an
XML document that has both <first> and <First> elements, which
have different meanings. This is a bad idea, and will cause nothing but
confusion! You should always try to give your elements distinct names,
for your sanity, and for the sanity of those to come after you.
Whitespace in PCDATA
• In XML, the whitespace stays.
This is a paragraph. It has a whole bunch
of space.
• In HTML
<P>This is a paragraph. It has a whole
bunch<BR> of space.</P>
Question 1
For the addresses in our Order XML, we used a common format of
“Address Line 1, Address Line 2, City, State, and Zip Code.’’ Other
applications need to be stricter with their addresses, and have
separate elements for street number, street name, and so on. Rewrite
the last version of the Order XML using the following information,
instead of the Address Line 1/Address Line 2 format:
❑ Street Number
❑ Street Name
❑ Apt. Number
❑ City
❑ State
❑ Zip Code
❑ Additional Information
Solution
As always, there are multiple ways this could be designed. One option
might be to use attributes, to break up information about the street
and the apartment, like this:
3.XML Namespaces
Question 1
Earlier we had the following XML document, in which we had to cancel
the default namespace:
<employee>
<name>Jane Doe</name>
<notes>
<p xmlns="http://www.w3.org/1999/xhtml">I've worked
with <name xmlns="">Jane Doe</name> for over a <em>year</em>
now.</p>
</notes>
</employee>
Assuming that this document is for the fictional Serna Ferna, Inc.,
company we’ve been using, create a namespace for employees, and
use it in this document. Be sure to keep the XHTML elements in their
namespace.
Solution
The URL we’ve been using for namespaces for Serna Ferna, Inc., has
been http://www.sernaferna .com, followed by something to indicate
the namespace being named. In this case, because we’re creating a
namespace for employees, so http://www.sernaferna.com/employee
makes sense.
Because we have a <name> element embedded inside an XHTML <p>
element, it makes sense to use prefixes, rather than default
namespaces, so the resulting document could look like this:
Validation
4.Document Type Definitions
The need to validate documents against a vocabulary is common in
markup languages. In fact, it is so common that the creators of XML
included a method for checking validity in the XML Recommendation.
An XML document is valid if its content matches its definition of
allowable elements, attributes, and other document pieces. By utilizing
special Document Type Definitions, or DTDs, you can check the
content of a document type with special parsers. The XML
Recommendation separates parsers into two categories—validating
and nonvalidating. Validating parsers, according to the
Recommendation, must implement validity checking using DTDs.
Therefore, if we have a validating parser, we can remove the content-
checking code from our application and depend on the parser to verify
the content of our XML document against our DTD.
The External DTD
In our example, we created a relatively simple DOCTYPE declaration;
we will look at some more
advanced DOCTYPE declaration features later.
<!ELEMENT name (first, middle, last)>
<!ELEMENT first (#PCDATA)>
<!ELEMENT middle (#PCDATA)>
<!ELEMENT last (#PCDATA)>
At this point we have completed the DTD. All of the children that were
listed in content models
now have their own element declarations. The final DTD should look
like the following:
<!ELEMENT dinosaurs (carnivore, herbivore, omnivore)>
<!ELEMENT carnivore (species, length, height, weight, speed, weapon,
discoverer, location, description)>
<!ELEMENT herbivore (species, length, height, weight, speed, weapon,
discoverer, location, description)>
<!ELEMENT omnivore (species, length, height, weight, speed, weapon,
discoverer, location, description)>
<!ELEMENT species (#PCDATA)>
<!ELEMENT length (#PCDATA)>
<!ELEMENT height (#PCDATA)>
<!ELEMENT weight (#PCDATA)>
<!ELEMENT speed (#PCDATA)>
<!ELEMENT weapon (part-of-body, description)>
<!ELEMENT part-of-body (#PCDATA)>
<!ELEMENT description (#PCDATA | b | i)*>
<!ELEMENT b (#PCDATA)>
<!ELEMENT i (#PCDATA)>
<!ELEMENT discoverer (name, year)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT year (#PCDATA)>
<!ELEMENT location (GPS | (country, region))>
<!ELEMENT GPS (#PCDATA)>
<!ELEMENT country (#PCDATA)>
<!ELEMENT region (#PCDATA)>
Save the file as dinosaurs.dtd.
XPath
When writing code to process XML, you often want to select specific
parts of an XML document to process in a particular way. For example,
you might want to select some invoices that fit a date range of
interest. Similarly, you may want to specifically exclude some part(s) of
an XML document from processing. For example, if you make basic
human resources data available on your corporate intranet, you
probably want to be sure not to display confidential information such
as salary for an employee. To achieve those basic needs, it is essential
to have an understanding of a technology that allows you to select a
part or parts of an XML document to process. The XML Path Language,
XPath, is designed to allow the developer to select specific parts of an
XML document.
XPath was designed specifically for use with Extensible Stylesheet
Language Transformations (XSLT), , and with XML Pointer (XPointer),
which is not discussed in detail in this book. More recently, XForms 1.0
makes use of XPath 1.0, too.
Serialized Document
In a serialized XML document we write start and end tags and, except
in XML documents of trivial length, there is a nested structure of
elements, such as in the following simple document:
<?xml version="1.0" encoding="UTF-8"?>
<!-- This is a comment. -->
<Book>
<Chapter>Some content</Chapter>
<Appendix>Some appendix content.</Appendix>
</Book>
By now, you should be familiar with such XML documents and how to
write well-formed XML. But how are these documents represented in
the XPath data model?
Context
In XPath, the context indicates the location of the node where a
processor is currently situated, so to speak. That node is called the
context node.
However, the context consists of more than just the context node. It
also includes a context position and a context size. Consider the
following XML document:
<Book>
<Chapter number="1">This is the first chapter</Chapter>
<Chapter number="2">This is the second chapter</Chapter>
<Chapter number="3">This is the third chapter</Chapter>
<Chapter number="4">This is the fourth chapter</Chapter>
<Chapter number="5">This is the fifth chapter</Chapter>
</Book>
Suppose the context node is the node that represents the
Chapterelement node for the second chapter. We can use the
position()and last()functions, which are described in more detail later in
this chapter, to show the position of the context node and the context
size.
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:template match="/">
<html>
<head> <title>This shows the context position and context
size.</title>
</head>
<body>
<h3>Context position and context size demo.</h3>
<xsl:apply-templates select="/Book/Chapter" />
</body>
</html>
</xsl:template>
<xsl:template match="Chapter">
<xsl:if test="position()=2">
<p>When the context node is the second <b>Chapter</b> element
node then</p>
<p>the context position is <xsl:value-of select="position()" /></p>
<p>and the context size is <xsl:value-of select="last()" />.</p>
<p>The text the <b> Chapter</b> element node contains is
'<xsl:value-of select="." />'.
</p> </xsl:if>
</xsl:template>
</xsl:stylesheet>
The simple HTML document created by the stylesheet is shown in
Figure.
The files Books.xml, Books.xsl,andBooks.htmlare included in the code
download. The instructions to run the code are described in XSLT.
Notice that in the value of the selectattribute of the xsl:value-
ofelement you see the position() function and the last()function. As you
see in Figure 7-1, the context position is 2 and the context size is 5.
In addition to the context node, the context position, and the context
size, the context also includes variable bindings that are in scope,
namespace declarations that are in scope, and a function library (the
XPath 1.0 function library).
What Is a Node?
A node is a representation in the XPath data model of a logical part of
an XML document.
In XPath 1.0 there are seven types of nodes:
❑Root node
❑Element node
❑Attribute node
❑Text node
❑Namespace node
❑Comment node
❑Processing Instruction node
Each node type is described in more detail in the following sections.
Root Node
The root node represents the document itself, independent of any
content it has. The root node is the apex of the hierarchy of nodes that
represents an XML document. The element node, which represents the
document element, is a child node of the root node. The root node may
also have child nodes, which are processing instruction nodes or
comment nodes that correspond to any processing instructions or
comments in the prolog of the serialized XML document.
The XML declaration and the document type declaration are not
children of the root node. Neither of those features of a serialized XML
document is represented in the XPath data model.
The root node’s text value is the concatenation of the values of all
descendant text nodes of the root node, in document order. Examine
the following XML document:
<MixedContent>
Mary had a <Emphasis>little</Emphasis> lamb.
</MixedContent>
The text value of this document is Maryhadalittlelamb.
The root node does not have a name.
Element Node
Each element in an XML document is represented as an element node
in the XPath data model.
Element nodes have a name made up of the namespace URI of the
element and the local part of its name. For developers it is easier to
work with a qualified name, also called a QName, which is a
namespace prefix followed by a colon character followed by the local
part of the element type name:
prefix:localpart
The string value of an element node is the concatenation of the values
of all its descendant text nodes, in document order.
An element node may represent an element that possesses a unique
ID attribute. If it does, the id() function can be used to access that
element node.
Attribute Node
Each attribute in an XML document is represented in the XPath model
as an attribute node. The element node with which the attribute node
is associated is said to be the parent node of the attribute
node.Attribute nodes have a name and a string value.
Text Node
Text content of an element node is represented in the XPath data
model as a text node.
The string value of a text node is its character data. A text node does
not have a name.
Namespace Node
All in-scope namespaces of an element node are represented as
namespace nodes. XPath takes an extravagant approach to
namespace nodes. Each element node has its own namespace node for
all in-scope namespaces. For example, imagine the XPath model of the
following code:
<Book xmlns="http://www.XMML.com/booknamespace">
<Chapter number="1">Some text content.</Chapter>
<Chapter number="2">Some different text content.</Chapter>
</Book>
The Bookelement node has a namespace node associated with the
namespace URI http://www.XMML .com/booknamespace. Each of the
Chapterelement nodes also has its own namespace node associated
with the same namespace URI,
http://www.XMML.com/booknamespace. This simple document has
three separate namespace nodes associated with the same
namespace URI. In complex
documents, large numbers of namespace nodes can be associated with
a single URI and some elements deep in the hierarchy can have
several namespace nodes.
The name()function returns the namespace prefix associated with the
namespace node. The self:: node()expression (which can be
abbreviated to a period character) returns the namespace URI of the
namespace node.
Comment Node
A comment node represents a comment in the XML document.
Comments in the document type declaration are not represented in the
XPath data model.
Processing Instruction Node
A processing instruction node in the XPath model represents a
processing instruction in the corresponding XML document. Processing
instructions in the document type declaration are not represented in
the XPath data model.
The name of a processing instruction node is its target (turn to Chapter
2 for more on processing instructions). The string value of a processing
instruction node is its content, excluding the target.
XPath 1.0 Types
XPath 1.0 has four expression types:
❑boolean
❑node-set
❑number
❑string
Booleans
In an XPath 1.0 expression a boolean value is written as one of the
values true()or false(). You may wonder why we don’t simply use the
values trueand false. It is possible that an XML developer might choose
to have a structure like this:
<true> ... some content
</true>
True is a legal XML name, and can be used to name an element.
As you’ll see later, the XPath way to select the trueelement node is
indistinguishable from the value true. By using the syntax true()and
false(), which technically are XPath functions, we remove the possible
ambiguity.
Node-Sets
A node-set is a set of XPath nodes. Technically, an XPath 1.0 node-set
is unordered. However, when used in XSLT, which is currently XPath’s
main use, processing of a node-set is always in the document order of
the nodes for forward axes and in reverse document order for reverse
axes. XPath axes are discussed later. Most axes, including the
childaxis, are forward axes.
Consider what document order means by examining the following
simple document:
<PurchaseOrder>
<Date>2005-01-01</Date>
<To>XMML.com</To>
<ShippingAddress>
<Street>123 Any Street</Street>
<City>Anytown</City>
<State>AZ</State>
</ShippingAddress>
<ZipCode>12345</ZipCode>
</PurchaseOrder>
The PurchaseOrderelement is first in document order. Document order
among the children of the PurchaseOrderelement is then Date, To,
ShippingAddress, and ZipCode. All the child nodes of
ShippingAddresscome earlier in document order than the
ZipCodeelement.
Numbers
In XPath, numbers are floating point numbers. There is no way to
directly represent an integer in XPath, although numeric functions will
typically return a whole number from, for example, the count()
function, which counts the number of nodes in a node-set.
Strings
A string value in XPath is a sequence of Unicode characters. Generally,
like XML, XPath is not limited to ASCII characters but uses the much
more extensive Unicode character set.
XPath 1.0 has no type corresponding to a date. All dates are treated in
XPath as strings. So, for example, manipulation of strings that
represent dates to extract the month from a date depends on knowing
exactly how the string is written, and on using various XPath string
manipulation functions.So far, we have talked about XPath in a pretty
abstract way. How is XPath written?
XSLT
XSLT, Extensible Stylesheet Language Transformations, is a very
important XML language in many XML workflows. In many business
situations, data is either stored as XML or can be made available from
a database as XML. XSLT is important because, typically, the way XML
is stored needs to be changed before it is used. Wherever the data
comes from, the XML might need to be presented to end-users or
might need to be shared with business partners in a format that is
convenient for those business partners. XSLT plays a key role in
converting XML to its presentation formats and restructuring XML to fit
the structures useful to business partners.
In this chapter we will learn:
❑ How XSLT can be used to convert XML for presentation or
restructure XML for business-to-business data interchange.
❑ How XSLT differs from conventional procedural languages.
❑ An XSLT transformation is described in terms of a source document
and a result document. However, under the hood, the transformation
taking place is a source tree (which uses the XPath data model) to a
result tree (which also uses the XPath data model).
❑ How the elements that make up an XSLT stylesheet are used. For
example, we look at how to use the xsl:value-of element to retrieve
values from the source tree which is being transformed, and look at
the xsl:copy and xsl:copy-of elements which, respectively, shallow
copy and deep copy nodes from the source tree.
❑ How to use XSLT variables and parameters.
What Is XSLT?
XSLT is a declarative programming language, written in XML, for
converting XML to some other output. Often the output is XML or
HTML, but in principle, XSLT can produce arbitrary output from any
given XML source document. For example, an XML document can be
restructured to conform to a business partner’s schema, or a selection
from an XML document can be made to correspond to specified
criteria, such as selecting invoices from a specified period. XSLT uses
XPath, to select the parts of the source XML document that are used in
the result document. All the XPath 1.0 functions are available to an
XSLT processor, and XSLT 1.0 has a few functions of its own.
Declarative Programming
The procedural programming approach contrasts with declarative
programming where you tell the computer what you want to achieve.
XSLT resembles SQL in that respect. For example, in SQL you tell the
relational database management system (RDBMS) to SELECT certain
columns, but you don’t expect to tell it how to retrieve the desired
data. XSLT is similar. You specify what the XSLT processor is to create
each time it comes across a particular pattern in the source tree.
To specify what the XSLT processor is to do you frequently use the
xsl:template element with a match attribute that contains the relevant
pattern. So if you wanted to create certain output for every Chapter
element in a source XML document you would have code like this:
<xsl:template match="Chapter">
<!-- The content of the <xsl:template> element defines what is to be
added -->
<!-- to the result tree. -->
</xsl:template>
Notice how the pattern Chapter appears as the value of the match
attribute of the xsl:template
element.
Let’s move on and create a simple XSLT stylesheet and look at how it
works.
Foundational XSLT Elements
We will create an example that makes a simple HTML web page from
the XML source document shown here:
<People>
<Person>
<Name>George H.W. Bush</Name>
<Description>George Bush was a late 20th century politician who was
elected as President of the United States.</Description>
</Person>
<Person>
<Name>Winston Churchill</Name>
<Description>Winston Churchill was a mid 20th Century British
politician who became famous as Prime Minister during the Second
World War.</Description>
</Person>
<Person>
<Name>John F. Kennedy</Name>
<Description>JFK, as he was affectionately known, was a United States
President who was assassinated in Dallas, Texas.</Description>
</Person>
</People>
As you can see the file, People.xml, contains brief information about
three famous twentieth-century politicians.
The following stylesheet, People.xsl, creates a simple HTML web page,
People.html, which
contains the name and description information about the politicians.
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0" >
<xsl:template match="/">
<html>
<head>
<title>Information about <xsl:value-of
select="count(/People/Person)" />people.</title>
</head>
<body>
<h3>Information about <xsl:value-of
select="count(/People/Person)" />people.</h3>
<br />
<xsl:apply-templates select="/People/Person" />
</body>
</html>
</xsl:template>
<xsl:template match="Person">
<h3><xsl:value-of select="Name" /></h3>
<p><xsl:value-of select="Description" /></p>
<br />
</xsl:template>
</xsl:stylesheet>
Web Modeling
• Modeling static & dynamic aspects of content,
hypertext, and presentation
• We focus on object-oriented analysis & design
– Analysis: Finding & discovering classes of objects/
concepts in a domain
– Design: Defining software objects & how they interact to
fulfill requirements.
Objects
• Software entities – like real-world entities - that
consist of states and behaviors
• States:
– Variables store the states of an object’s properties
– Hidden from the outside world (data encapsulation)
• Behaviors:
• Methods define the object’s behaviors
• Used by objects to communicate with other objects
• Classes
– blueprints for creating objects of a particular type
Model-Driven ...
• Systematic development on basis of models
• Models become the first hand artifacts in the software development
cycle
• Key concepts
– abstraction from implementation detail
– systematic transformations
• Related Terminology
– Model Driven [Software] Engineering (MDE),
– Model Driven [Software] Development (MDD/MDSD),
– Model Driven Architecture (MDA)
– Model Driven Web Engineering (MDWE)
What is Model Driven Architecture?
• MDA is defined and developed by the Object Management Group
(OMG) since March 2001
• MDA is:
– "Model-Driven …"-framework for software development, defined by
the OMG
– open, vendor-neutral approach to interoperability using OMG's
modeling specifications:
• Unified Modelling Language (UML), Meta-Object Facility (MOF) and
Common Warehouse Model (CWM)
• Main ideas:
– Addresses the complete system development life cycle
– Separate specification from implementation
– Specify a system that is independent of a platform
– Transform a platform-independent (PIM) system specification into a
specific platform (PSM)
– Code generation
Actors I
• PC Chair
– creating the conference
– determining the conference topics (or tracks) and subjects
– establishing the Program Committee
– defining the final list of accepted and rejected papers
– defining the conference deadlines: submission, review, and
notification.
• PC Member
– evaluating a set of papers assigned to him
– indicating another person as a reviewer of a paper
– advising the PC Chair for the final list of accepted papers
Actors II
• Reviewer
– responsible for reviewing a paper
• Author
– submitting a paper for acceptance at the conference
– PC Members and Reviewers may also be Authors, they must have
different Ids for each role
Introduction
• Purpose: To model the information requirements of a Web application
– Diagramming the structural (i.e., information objects) & behavioral
aspects of the information.
– NOT concerned with navigation.
• Primary Models
– Class diagrams – enough for static applications.
– State machine diagrams – captures dynamic aspects
OOHDM
Web Engineering (703512)
WebML
Web Engineering (703512)
Mandatory reading(Learning)
– Web Engineering
• Chapter 3
Self Learning
• Suggested
– First International Workshop on Web-Oriented SoftwareTechnology
• http://www.dsic.upv.es/~west/iwwost01/
– UML-based Web Engineering
• http://www.pst.informatik.uni-muenchen.de/projekte/uwe/index.html