0% found this document useful (0 votes)
54 views112 pages

Unit - I

The document discusses various markup languages including SGML, HTML, XML and related technologies like JavaScript, VBScript, ASP, JSP. It explains the evolution of HTML from SGML and the benefits of XML like simplicity, extensibility and self-description. The document also covers XML standards like XPath, XSLT, XML schema and compares XML with databases and EDI.

Uploaded by

excitekarthik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views112 pages

Unit - I

The document discusses various markup languages including SGML, HTML, XML and related technologies like JavaScript, VBScript, ASP, JSP. It explains the evolution of HTML from SGML and the benefits of XML like simplicity, extensibility and self-description. The document also covers XML standards like XPath, XSLT, XML schema and compares XML with databases and EDI.

Uploaded by

excitekarthik
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 112

UNIT - I

 SGML
 HTML
 DHTML
 XHTML
 JAVA SCRIPT
 VB SCRIPT
 ASP
 JSP
 AND SO ????? NEXT ????
HTML was defined using SGML
 Standard Generalized Mark-up Language
 A meta-language for defining languages
 Complex, sophisticated, powerful
Problems with SGML
 Too complicated a language
 Rules are too strict
 Not good in a distributed environment
 Can’t mix different data together
 Hyper Text Markup Language
 A simple language for displaying text
 Started with very few tags …
 Language evolved, as more tags were added
 Forms,tables,fonts,frames
XML - Introduction
HTML SMIL SpeechML XUL
XHTML MathML RDF

TEI ...

...

XML
SGML
 XML stands for Extensible Markup Language
 XML is a markup language much like HTML
 XML was designed to describe data[carry
data], not to display data
 XML is a Well Formed document
 XML tags are not predefined. You must
define your own tags
 XML is designed to be self-descriptive
 XML is a W3C Recommendation
BENEFITS
 Simplicity  Facilitates the comparison and
aggregation of data
 Openness
 Extensibility  Can embed multiple data types
 Self-description
 Can embed existing data
 Contains machine-readable
context information
 Provides a 'one-server view' for
distributed data
 Supports multilingual
documents and Unicode
 Rapid adoption by industry
 Separates the process and its
data contents-loosely coupled
XML stands for eXtensible Markup Language
HTML is used to mark up XML is used to mark up
text so it can be displayed to data so it can be processed
users by computers
HTML describes both XML describes only
structure (e.g. <p>, <h2>, content, or “meaning”
<em>) and appearance (e.g.
<br>, <font>, <i>)

HTML uses a fixed, In XML, you make up


unchangeable set of tags your own tags
 HTML and XML look similar, because they are both SGML
languages (SGML = Standard Generalized Markup Language)
 Both HTML and XML use elements enclosed in tags (e.g.
<body>This is an element</body>)
 Both use tag attributes (e.g.,
<font face="Verdana" size="+1" color="red">)
 Both use entities (&lt;, &gt;, &amp;, &quot;, &apos;)
 More precisely,
 HTML is defined in SGML
 XML is a (very small) subset of SGML
 HTML is for humans
 HTML describes web pages
 You don’t want to see error messages about the web pages
you visit
 Browsers ignore and/or correct as many HTML errors as they
can, so HTML is often sloppy
 XML is for computers
 XML describes data
 The rules are strict and errors are not allowed
▪ In this way, XML is like a programming language
 Current versions of most browsers can display XML
▪ However, browser support of XML is spotty at best
ADVANTAGES OF XML OVER
EDI
 Electronic Document Interchange (EDI) has been
used in e-commerce for many years
 EDI exchanges documents between commercial
partners regarding a transaction
 EDI requires special proprietary software, but
EDI data will soon travel inside XML
 EDI don’t easily support the needs for
internationalization and localization
 EDI failed to become the universal data
description language due to its high cost
and complexity, blocking small businesses
 EDI-to-XML and XML-to-EDI translation is
already taking place, ebXML group taking
the lead
 Companies running different accounting
and business management applications
will exchange documents in a cross-system
flow
 ebXML is mapping business processes to
facilitate XML to XML B2B
ADVANTAGES OF XML OVER
DATABASES
 XML is a structured document that includes not only the data
but also metadata that describes that data’s content and
context.
 Relational and object-oriented databases and formats can
represent data as well as metadata, but their formats are
text based.
 Most databases use a proprietary binary format to
represent their information.
 XML’s greatest strengths is that processing tools have
become relatively widespread and inexpensive.
XML BASED STANDARDS
 XPATH
 XPath is a syntax for defining parts of an XML document
 XPath uses path expressions to navigate in XML documents
 XPath contains a library of standard functions
 XPath is a major element in XSLT
 XPath is a W3C Standard

 XSD
 defines elements that can appear in a document
 defines attributes that can appear in a document
 defines which elements are child elements
 defines the order of child elements
 defines the number of child elements
 defines whether an element is empty or can include text
 defines data types for elements and attributes
 defines default and fixed values for elements and attributes
 XSL
 XSL describes how the XML document should be displayed!
 XSL consists of three parts:
▪ XSLT - a language for transforming XML documents
▪ XPath - a language for navigating in XML documents
▪ XSL-FO - a language for formatting XML documents

 XSLT
 A common way to describe the transformation process is to say that XSLT
transforms an XML source-tree into an XML result-tree.
 XSLT stands for XSL Transformations
 XSLT is the most important part of XSL
 XSLT transforms an XML document into another XML document
 XSLT uses XPath to navigate in XML documents
 XSLT is a W3C Recommendation
Structuring With Schemas
XML document includes the following

 The xml declaration


 The document type declaration
 The element data
 The attribute data
 The character data or XML content
 All XML elements must have a closing tag
 XML tags are case sensitive
 All XML elements must have a proper nesting
 All XML Documents must contain a single root element
 Attribute values must be quoted
 Attributes may only appear once in the same start tag
 Attribute values cannot contain references to external entities
 All entities except amp,lt,gt,apos,and quot must be declared
before they are used
DTD
Document Type Definition
 The purpose of a DTD (Document Type
Definition) is to define the legal building
blocks of an XML document.
 A DTD defines the document structure with a
list of legal elements and attributes.
 A DTD can be declared inline inside an XML
document, or as an external reference.
 If the DTD is declared inside the XML file, it should be wrapped in a
DOCTYPE definition with the following syntax:
 <!DOCTYPE root-element [element-declarations]> Example XML
document with an internal DTD:
 <?xml version="1.0"?>
<!DOCTYPE note [
<!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
]>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend</body>
</note>
 If the DTD is declared in an external file, it should be wrapped in a DOCTYPE definition with
the following syntax:
 <!DOCTYPE root-element SYSTEM "filename"> This is the same XML document as above,
but with an external DTD.
 <?xml version="1.0"?>
<!DOCTYPE note SYSTEM "note.dtd">
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
And this is the file "note.dtd" which contains the DTD:
 <!ELEMENT note (to,from,heading,body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT from (#PCDATA)>
<!ELEMENT heading (#PCDATA)>
<!ELEMENT body (#PCDATA)>
 The Building Blocks of XML Documents
 Seen from a DTD point of view, all XML
documents (and HTML documents) are made
up by the following building blocks:
 Elements
 Attributes
 Entities
 PCDATA
 CDATA
 Elements
 Elements are the main building blocks of both XML and HTML
documents.
 Attributes
 Attributes provide extra information about elements
 Entities
 Some characters have a special meaning in XML, like the less than sign
(<) that defines the start of an XML tag.
 PCDATA
 PCDATA means parsed character data.
 Think of character data as the text found between the start tag and the
end tag of an XML element.
 PCDATA is text that WILL be parsed by a parser. The text will be
examined by the parser for entities and markup.
 CDATA
 CDATA means character data.
 CDATA is text that will NOT be parsed by a parser. Tags inside the text
will NOT be treated as markup and entities will not be expanded.
XML Schema
 An XML schema describes the structure of an
XML document.
 XML Schema is an XML-based alternative to
DTD.
 The XML Schema language is also referred to
as XML Schema Definition (XSD).
 The purpose of an XML Schema is to define the legal
building blocks of an XML document, just like a DTD.
 An XML Schema:
 defines elements that can appear in a document
 defines attributes that can appear in a document
 defines which elements are child elements
 defines the order of child elements
 defines the number of child elements
 defines whether an element is empty or can include
text
 defines data types for elements and attributes
 defines default and fixed values for elements and
attributes
 XML
 DTD
 <?xml version="1.0"?>
 <!ELEMENT note (to,
<note>
from, heading, body)>
<to>Tove</to>
<!ELEMENT to
<from>Jani</from>
(#PCDATA)>
<heading>Reminder</
<!ELEMENT from
heading>
(#PCDATA)>
<body>Don't forget
<!ELEMENT heading
me this
(#PCDATA)>
weekend!</body>
<!ELEMENT body
</note>
(#PCDATA)>
 <?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3schools.com"
xmlns="http://www.w3schools.com"
elementFormDefault="qualified">
<xs:element name="note">
<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
 XML Schemas define the elements of your XML files.
 A simple element is an XML element that contains only text. It cannot contain
any other elements or attributes.
 Defining a Simple Element
 The syntax for defining a simple element is:
 <xs:element name="xxx" type="yyy"/> where xxx is the name of the element and
yyy is the data type of the element.
 XML Schema has a lot of built-in data types. The most common types are:
 xs:string
 xs:decimal
 xs:integer
 xs:boolean
 xs:date
 xs:time
 Example
 <lastname>Refsnes</lastname>
<age>36</age>
<dateborn>1970-03-27</dateborn>
 A complex element is an XML element that contains other elements and/or attributes.
 There are four kinds of complex elements:
 empty elements
 elements that contain only other elements
 elements that contain only text
 elements that contain both other elements and text
 Note: Each of these elements may contain attributes as well!

 EXAMPLE
 <xs:element name="employee" type="fullpersoninfo"/>

<xs:complexType name="personinfo">
<xs:sequence>
<xs:element name="firstname" type="xs:string"/>
<xs:element name="lastname" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="fullpersoninfo">
<xs:complexContent>
<xs:extension base="personinfo">
<xs:sequence>
<xs:element name="address" type="xs:string"/>
<xs:element name="city" type="xs:string"/>
<xs:element name="country" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
XML PROCESSING
DOM
SAX
 The JavaTM API for XML Processing (JAXP) includes the
basic facilities for working with XML documents through the
following standardized set of Java Platform APIs. There are
two types of XML Parsers namely
 Document Object Model (DOM)
 Simple API For XML Parsing (SAX)
 The XML DOM (Document Object Model) defines a standard
way for accessing and manipulating XML documents.

 The DOM presents an XML document as a tree structure, with


elements, attributes, and text as nodes.
HISTORICAL BACKGROUND
 DOM is a standard defined by the W3C, just like XML
 DOM was not designed specifically for Java technology
(unlike SAX)
 DOM is cross-platform and cross language
 Uses OMG’s IDL to define interfaces
 IDL to language binding
Creates
XML Tree
Input
Document
Parser
 The XML DOM views an XML document as a
tree-structure. The tree structure is called a
node-tree.
 All nodes can be accessed through the tree.
Their contents can be modified or deleted, and
new elements can be created.
 The nodes in the node tree have a hierarchical
relationship to each other.
 The terms parent, child, and sibling are used to
describe the relationships. Parent nodes have
children. Children on the same level are called
siblings (brothers or sisters).
 In a node tree, the top node is called the
root
 Every node, except the root, has exactly one
parent node
 A node can have any number of children
 A leaf is a node with no children
 Siblings are nodes with the same parent
EXAMPLE XML DOCUMENT
DOM TREE HIERARCHY <?xml version="1.0"?>
<people>
 A document node <person born="1912">
contains <name>
<first_name>Alan</first_name>
 one element node (root <last_name>Turing</last_name>
</name>
element node) <profession>computer
 one or more processing scientist</profession>
</person>
instruction nodes </people>
 An element node may DOM TREE EXAMPLE
contain  XML Document node
 other element nodes  element node “people”
 one or more text nodes ▪ element node “person”
▪ element node “name”
 one or more attribute  element node “first_name”
nodes * text node “Alan”
 An attribute node contain » element node “last_name”
* text node “Turing”
 a text node ▪ element node “profession”
» text node “computer scientist”
▪ attribute node “born”
» text node “1912”
 All modern browsers xmlDoc=new ActiveXObject
have a build-in XML ("Microsoft.XMLDOM");
xmlDoc.async="false";
parser that can be used xmlDoc.load(“people.xml")
;
to read and manipulate
 Code explained:
XML.
 The first line creates an empty
Microsoft XML document
object.
 The parser reads XML  The second line turns off
asynchronized loading, to
into memory and make sure that the parser will
not continue execution of the
converts it into an XML script before the document is
fully loaded.
DOM object that can be  The third line tells the parser
to load an XML document
accesses with JavaScript called “people.xml".
 SAX and DOM are standards for XML parsers--program APIs
to read and interpret XML files
 DOM is a W3C standard
 SAX is an ad-hoc (but very popular) standard
 SAX was developed by David Megginson and is open source
 There are various implementations available
 Java implementations are provided as part of JAXP (Java API
for XML Processing)
 JAXP is included as a package in Java 1.4
 JAXP is available separately for Java 1.3
 Unlike many XML technologies, SAX and DOM are
relatively easy
 SAX (Simple API for XML) is an event-driven model for processing XML.
Most XML processing models (for example: DOM and XPath) build an
internal, tree-shaped representation of the XML document.
 Event Handlers
DTDHandlers, for accessing the contents of XML Document-Type Definitions;
ErrorHandlers, for low-level access to parsing errors
DocumentHandlers, for accessing the contents of the document.
A SAX processor will pass the following events to a DocumentHandler:
 The start of the document.
 A processing instruction element.
 A comment element.
 The beginning of an element, including that element's attributes.
 The text contained within an element.
 The end of an element.
 The end of the document.
 SAX works through callbacks: you call the parser, it calls
methods that you supply

Your program

startDocument(...)
The SAX parser
startElement(...)
main(...)
parse(...) characters(...)
endElement( )
endDocument( )
THE SAMPLE CLASS, I
 // For simplicity, we let the operating system handle exceptions
// In "real life" this is poor programming practice
public class Sample {
public static void main(String args[]) throws Exception {
 // Create a parser factory
SAXParserFactory factory = SAXParserFactory.newInstance();
 // Tell factory that the parser must understand namespaces
factory.setNamespaceAware(true);
 // Make the parser
SAXParser saxParser = factory.newSAXParser();
XMLReader parser = saxParser.getXMLReader();

THE HANDLER CLASS, I


 public class Handler extends DefaultHandler {
 DefaultHandler is an adapter class that defines these methods and others as do-
nothing methods, to be overridden as desired
 We will define three very similar methods to handle (1) start tags, (2) contents, and
(3) end tags--our methods will just print a line
 Each of these three methods could throw a SAXException
 DOM reads the entire XML document into memory and
stores it as a tree data structure
 SAX reads the XML document and calls one of your methods
for each element or block of text that it encounters
 Consequences:
 DOM provides “random access” into the XML document
 SAX provides only sequential access to the XML document
 DOM is slow and requires huge amounts of memory, so it cannot be
used for large XML documents
 SAX is fast and requires very little memory, so it can be used for huge
documents (or large numbers of documents)
▪ This makes SAX much more popular for web sites
 Some DOM implementations have methods for changing the XML
document in memory; SAX implementations do not
PRESENTATION TECHNOLOGIES
 XSL
 XFORMS
 XHTML
XSL & XSLT
 XSL is a language for expressing style sheets. An XSL style sheet
is, like with CSS, a file that describes how to display an XML
document of a given type. XSL shares the functionality and is
compatible with CSS2.
 A transformation language for XML documents: XSLT. Originally
intended to perform complex styling operations, like the
generation of tables of contents and indexes, it is now used as a
general purpose XML processing language. XSLT is thus widely
used for purposes other than XSL, like generating HTML web
pages from XML data.
 Advanced styling features, expressed by an XML document type
which defines a set of elements called Formatting Objects, and
attributes and adding more complex ones.
 Styling requires a source XML documents,
containing the information that the style
sheet will display and the style sheet itself
which describes how to display a document
of a given type.
 <scene>
 <FX>General Road Building noises.</FX>
<speech speaker="Prosser"> Come off it Mr
Dent, you can't win you know. There's no
point in lying down in the path of progress.
</speech>
 <speech speaker="Arthur"> I've gone off the
idea of progress. It's overrated </speech>
 </scene>
 ... <xsl:template match="FX">
 <fo:block font-weight="bold">
 <xsl:apply-templates/>
 </fo:block> </xsl:template>
 <xsl:template
match="speech[@speaker='Arthur']"> <fo:block
background-color="blue"> <xsl:value-of
select="@speaker"/>:
 <xsl:apply-templates/>
 </fo:block>
 </xsl:template> ...
 XSL-FO is a language for formatting XML data
for output to screen, paper or other media.
 Styling is both about transforming and
formatting information.
 XSL-FO Documents
 XSL-FO documents are XML files with output
information.
 XSL-FO documents are stored in files with a .fo
or a .fob file extension. You can also store XSL-
FO documents with an .xml extension
 Pages
 Regions
 Block areas
 Line areas
 Inline areas
 XSL-FO Pages
 XSL-FO output is formatted into pages. Printed
output will normally go into many separate pages.
Browser output will often go into one long page.
 XSL-FO Pages contain Regions.
 XSL-FO Regions
 Each XSL-FO Page contains a number of Regions:
 region-body (the body of the page)
 region-before (the header of the page)
 region-after (the footer of the page)
 region-start (the left sidebar)
 region-end (the right sidebar)
 XSL-FO Regions contain Block areas.
 XSL-FO Block Areas
 XSL-FO Block areas define small block elements (the
ones that normally starts with a new line) like
paragraphs, tables and lists.
 XSL-FO Block areas can contain other Block areas, but
most often they contain Line areas.
 XSL-FO Line Areas
 XSL-FO Line areas define text lines inside Block areas.
 XSL-FO Line areas contain Inline areas.
 XSL-FO Inline Areas
 XSL-FO Inline areas define text inside Lines (bullets,
single character, graphics, and more).
 XSL stands for EXtensible Stylesheet Language
 What is XSLT?
 XSLT stands for XSL Transformations
 XSLT is the most important part of XSL
 XSLT transforms an XML document into another XML
document
 XSLT uses XPath to navigate in XML documents
 XSLT is a W3C Recommendation
 We want to transform the following XML document
("cdcatalog.xml") into XHTML:
<?xml version="1.0" encoding="ISO-8859-1"?>
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist> <country>USA</country>
<company>Columbia</company> <price>10.90</price>
<year>1985</year>
</cd> . . .
</catalog>
 Then you create an XSL Style Sheet ("cdcatalog.xsl") with a transformation template:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th align="left">Title</th>
<th align="left">Artist</th>
</tr>
<xsl:for-each select="catalog/cd">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
 The result is:
XFORMS
Next generation of HTML forms
 XForms is the next generation of HTML forms.
 XForms uses XML to create input forms on the Web.
 XForms is richer and more flexible than HTML forms
 XForms will be the forms standard in XHTML 2.0
 XForms is platform and device independent
 XForms separates data and logic from presentation
 XForms uses XML to define form data
 XForms stores and transports data in XML documents
 XForms contains features like calculations and
validations of forms
 XForms reduces or eliminates the need for scripting
 XForms is a W3C Recommendation
 An HTML form makes it possible for web
applications to accept input from a user.
 web users do complex transactions that are
starting to exceed the limitations of standard
HTML forms.
 XForms provides a richer, more secure, and
device independent way of handling web
input. We should expect future web solutions
to demand the use of XForms-enabled
browsers .
 XForms uses XML for data definition and HTML or XHTML
for data display.
 XForms separates the data logic of a form from its
presentation. This way the XForms data can be defined
independent of how the end-user will interact with the
application.
 With XForms, the rules for describing and validating data
are expressed in XML.
 With XForms, the data displayed in a form are stored in an
XML document, and the data submitted from the form,
are transported over the internet using XML.
 The data content is coded in, and transported as Unicode
bytes.
 XForms device independent, because the data
model can be used for all devices.
 The presentation can be customized for
different user interfaces, like mobile phones,
handheld devices, and Braille readers for the
blind.
 XForms is device independent and based on
XML, it is also possible to add XForms elements
directly into other XML applications like
VoiceXML (speaking web data), WML (Wireless
Markup Language), and SVG (Scalable Vector
Graphics).
 XForms is the next generation of HTML forms
 XForms is richer and more flexible than HTML forms
 XForms will be the forms standard in XHTML 2.0
 XForms is platform and device independent
 XForms separates data and logic from presentation
 XForms uses XML to define form data
 XForms stores and transports data in XML documents
 XForms contains features like calculations and
validations of forms
 XForms reduces or eliminates the need for scripting
 XForms is a W3C Recommendation
 The XForms Model
The XForms model is used to describe the data. The data
model is an instance (a template) of an XML document. The
XForms model defines a data model inside a <model>
element:
<model>
<instance>
<person>
<fname/>
<lname/>
</person>
</instance>
<submission id="form1" action="submit.asp"
method="get"/>
</model>
 The XForms model uses a <submission> element to
describe how to submit the data.
 The XForms user interface is used to display and
input the data. The user interface elements of
XForms are called controls (or input controls)
 XForms is not designed to work alone. There is no
such thing as an XForms document.
 XForms has to run inside another XML document. It
could run inside XHTML 1.0, and it will run inside
XHTML 2.0.
All together it looks as below Output seems like
<xforms>
<model>
<instance>
<person> <fname/> <lname/>
</person> </instance>
<submission id="form1"
action="submit.asp"
method="get"/>
</model>
<input ref="fname"><label>First
Name</label></input> <input
ref="lname"><label>Last
Name</label></input> <submit
submission="form1">
<label>Submit</label>
</submit>
</xforms>
XHTML
 XHTML stands for
EXtensible HyperText  XHTML elements must be
Markup Language properly nested
 XHTML is aimed to replace  XHTML elements must
HTML always be closed
 XHTML is almost identical  XHTML elements must be
to HTML 4.01 in lowercase
 XHTML is a stricter and  XHTML documents must
cleaner version of HTML have one root element
 XHTML is HTML defined as
an XML application
 XHTML is a W3C
Recommendation
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-
strict.dtd">
<html>
<head>
<title>simple document</title>
</head>
<body> <p>a simple paragraph</p> </body>
</html>
 The 3 Document Type Definitions
 DTD specifies the syntax of a web page in SGML.
 DTD is used by SGML applications, such as HTML, to specify rules that
apply to the markup of documents of a particular type, including a set
of element and entity declarations.
 XHTML is specified in an SGML document type definition or 'DTD'.
 An XHTML DTD describes in precise, computer-readable language,
the allowed syntax and grammar of XHTML markup.
 There are currently 3 XHTML document types:
 STRICT
 TRANSITIONAL
 FRAMESET
 XHTML 1.0 specifies three XML document types that correspond to three DTDs:
 Strict
 Transitional
 Frameset
XHTML 1.0 Strict
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
We can use this when you want really clean markup, free of presentational clutter.
We can use this together with Cascading Style Sheets.
XHTML 1.0 Transitional
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
We can use this when you need to take advantage of HTML's presentational
features and when you want to support browsers that don't understand Cascading
Style Sheets.
XHTML 1.0 Frameset
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
We can use this when you want to use HTML Frames to partition the browser
window into two or more frames.
 Why XHTML Modularization?
By splitting XHTML into modules, the W3C
(World Wide web Consortium) has created
small and well-defined sets of XHTML
elements that can be used separately for
small devices, or combined with other XML
standards into larger and more complex
applications.
Some of the modules are as below
Manipulation & Transformation
Technologies
 XSLT
 XLINK
 XPATH
 XQuery
XSLT
 XSL stands for EXtensible Stylesheet Language,
and is a style sheet language for XML
documents.
 XSLT stands for XSL Transformations.
 CSS = Style Sheets for HTML
 XSL = Style Sheets for XML
 XSL consists of three parts:
 XSLT - a language for transforming XML
documents
 XPath - a language for navigating in XML
documents
 XSL-FO - a language for formatting XML
documents
 XSLT is a language for transforming XML
documents into XHTML documents or to
other XML documents.
 XPath is a language for navigating in XML
documents
 XSLT is the most important part of XSL.
 XSLT is used to transform an XML document into another XML
document, or another type of document that is recognized by a
browser, like HTML and XHTML. Normally XSLT does this by
transforming each XML element into an (X)HTML element.
 With XSLT you can add/remove elements and attributes to or from
the output file. You can also rearrange and sort elements, perform
tests and make decisions about which elements to hide and
display, and a lot more.
 A common way to describe the transformation process is to say
that XSLT transforms an XML source-tree into an XML result-
tree.
 XSLT Uses XPath
 XSLT uses XPath to find information in an XML document. XPath is
used to navigate through elements and attributes in XML
documents.
 In the transformation process, XSLT uses
XPath to define parts of the source document
that should match one or more predefined
templates. When a match is found, XSLT will
transform the matching part of the source
document into the result document.
XLINK
 XLink defines a standard way of creating
hyperlinks in XML documents.
 XPointer allows the hyperlinks to point to
more specific parts in the XML document.
 XLink is short for XML Linking Language
 XLink is used to create hyperlinks in XML documents
 Any element in an XML document can behave as a link
 XLink supports simple links (like HTML) and extended links
(for linking multiple resources together)
 With XLink, the links can be defined outside the linked files
 ####################################
############
 XPointer is short for XML Pointer Language
 XPointer allows the links to point to specific parts of an
XML document
 XPointer uses XPath expressions to navigate in the XML
document
 XLink Syntax Example
 In HTML, we know (and all the <?xml version="1.0"?>
browsers know!) that the <a> <homepages
element defines a hyperlink. xmlns:xlink="http://www.w3.o
However, this is not how it rg/1999/xlink">
works with XML. In XML <homepage
documents, you can use xlink:type="simple"
whatever element names you xlink:href="http://www.w3scho
want - therefore it is impossible ols.com">Visit
for browsers to predict what W3Schools</homepage>
hyperlink elements will be called <homepage
in XML documents. xlink:type="simple"
 The solution for creating links in xlink:href="http://www.w3.org
XML documents was to put a ">Visit W3C</homepage>
marker on elements that should </homepages>
act as hyperlinks.
XPATH
 XPath is used to navigate through elements and
attributes in an XML document.
 XPath is a language for finding information in an
XML document.
 XPath is a syntax for defining parts of an XML
document
 XPath uses path expressions to navigate in XML
documents
 XPath contains a library of standard functions
 XPath is a major element in XSLT
 XPath is a W3C recommendation
 XPath Terminology
 Nodes
 In XPath, there are seven kinds of nodes:
element, attribute, text, namespace,
processing-instruction, comment, and
document nodes.
 Parent
 Each element and attribute has one parent.
 Children
 Element nodes may have zero, one or more
children.
 Siblings
 Nodes that have the same parent.
 Ancestors
 A node's parent, parent's parent, etc.
 Descendants
 A node's children, children's children, etc.
 XPath is a syntax for defining parts of an
XML document
 XPath uses path expressions to navigate
in XML documents
 XPath contains a library of standard
functions
 XPath is a major element in XSLT
 XPath is a W3C Standard
XPath Terminology
 Nodes
In XPath, there are seven kinds of nodes: element,
attribute, text, namespace, processing-instruction,
comment, and document (root) nodes. XML documents
are treated as trees of nodes. The root of the tree is called
the document node (or root node).
 Relationship of Nodes
 Parent
 Children
 Siblings
 Ancestors
 Descendants
 Predicates
 Selecting Unknown  Selecting several
Nodes paths
XQUERY
 XQuery is to XML what SQL is to database tables.
 XQuery was designed to query XML data.
 XQuery is designed to query XML data - not just XML
files, but anything that can appear as XML, including
databases.
 XQuery is the language for querying XML data
 XQuery for XML is like SQL for databases
 XQuery is built on XPath expressions
 XQuery is supported by all major databases
 XQuery is a W3C Recommendation
 Extract information to use in a Web Service
 Generate summary reports
 Transform XML data to XHTML
 Search Web documents for relevant
information
 XQuery is the language for querying XML
data
 XQuery for XML is like SQL for databases
 XQuery is built on XPath expressions
 XQuery is supported by all the major
database engines (IBM, Oracle, Microsoft,
etc.)
 XQuery is a W3C Recommendation
Example XML file <title lang="en">XQuery Kick Start</title>
<author>James McGovern</author>
<?xml version="1.0" encoding="ISO-8859-1" <author>Per Bothner</author>
?> <!-- Edited by XMLSpy® --> <author>Kurt Cagle</author>
- <bookstore> <author>James Linn</author>
- <book category="COOKING"> <author>Vaidyanathan
<title lang="en">Everyday Italian</title> Nagarajan</author>
<author>Giada De Laurentiis</author> <year>2003</year>
<year>2005</year> <price>49.99</price>
<price>30.00</price> </book>
</book> - <book category="WEB">
- <book category="CHILDREN"> <title lang="en">Learning XML</title>
<title lang="en">Harry Potter</title> <author>Erik T. Ray</author>
<author>J K. Rowling</author> <year>2003</year>
<year>2005</year> <price>39.95</price>
<price>29.99</price> </book>
</book> </bookstore>
- <book category="WEB">
Functions
XQuery uses functions to extract data from Predicates
XML documents. XQuery uses predicates to limit the extracted data
The doc() function is used to open the from XML documents.
"books.xml" file: The following predicate is used to select all the
book elements under the bookstore element that
have a price element with a value that is less than
doc("books.xml") 30:
Path Expressions doc("books.xml")/bookstore/book[price<30]The
XQuery uses path expressions to navigate XQuery above will extract the following:
through elements in an XML document. <book category="CHILDREN">
The following path expression is used to select <title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
all the title elements in the "books.xml" file: <year>2005</year>
doc("books.xml")/bookstore/book/title(/bookst <price>29.99</price>
ore selects the bookstore element, /book </book>
selects all the book elements under the
bookstore element, and /title selects all the
title elements under each book element)
The XQuery above will extract the following:
<title lang="en">Everyday Italian</title>
<title lang="en">Harry Potter</title>
<title lang="en">XQuery Kick
Start</title>
<title lang="en">Learning XML</title>
With FLWOR
FLWOR is an acronym for "For, Let, The following FLWOR expression
Where, Order by, Return" will select exactly the same as the
 The for clause selects all book path expression above:
elements under the bookstore for $x in
element into a variable called $x. doc("books.xml")/bookstore/book
 The where clause selects only book where $x/price>30 return $x/title
elements with a price element with a The result will be:
value greater than 30. <title lang="en">XQuery Kick
 The order by clause defines the sort- Start</title>
order. Will be sort by the title <title lang="en">Learning
element. XML</title>
 The return clause specifies what With FLWOR you can sort the result:
should be returned. Here it returns for $x in
the title elements. doc("books.xml")/bookstore/book
Example where $x/price>30 order by $x/title
doc("books.xml")/bookstore/book[pric return $x/title
e>30]/title

You might also like