Presentation Technologies
Presentation Technologies
1) XSL
2) XFORMS
3) XHTML
</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:
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
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>
XHTML:
XHTML stands for EXtensible HyperText Markup Language. XHTML is aimed to
replace HTML. XHTML is almost identical to HTML 4.01. XHTML is a stricter and cleaner
version of HTML. XHTML is HTML defined as an XML application. XHTML is a W3C
Recommendation. XHTML elements must be properly nested. XHTML elements must always be
closed. XHTML elements must be in lowercase. XHTML documents must have one root element.
<!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 :
1) DTD specifies the syntax of a web page in SGML.
2) 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.
3) XHTML is specified in an SGML document type definition or 'DTD'.
XHTML 1.0 specifies three XML document types that correspond to three DTDs:
i. Strict
ii. Transitional
iii. 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:
TRANSFORMATION:
• XSLT
• XLINK
• XPATH
• XQuery
XLINK:
XLink Syntax:
In HTML, we know (and all the browsers know!) that the <a> element defines a
hyperlink. However, this is not how it works with XML. In XML documents, you can use
whatever element names you want - therefore it is impossible for browsers to predict what
hyperlink elements will be called in XML documents.The solution for creating links in
XML documents was to put a marker on elements that should act as hyperlinks.
Example:
<?xml version="1.0"?>
<homepages xmlns:xlink="http://www.w3.org/1999/xlink">
<homepage xlink:type="simple"
xlink:href="http://www.w3schools.com">Visit W3Schools</homepage><homepage
xlink:type="simple" xlink:href="http://www.w3.org">Visit W3C</homepage>
</homepages>
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.
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
i. Parent
ii. Children
iii. Siblings
iv. Ancestors
v. Descendants
Predicates:
Selecting Unknown Nodes:
XQuery uses path expressions to navigate through elements in an XML document.The following
path expression is used to select all the title elements in the "books.xml" file:
doc("books.xml")/bookstore/book/title(/bookstore selects the bookstore element, /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>
Predicates:
XQuery uses predicates to limit the extracted data from XML documents. 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 30: doc("books.xml")/bookstore/book[price<30]The XQuery
above will extract the following:
<book category="CHILDREN">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
With FLWOR:
FLWOR is an acronym for "For, Let, Where, Order by, Return". The for clause selects
all book elements under the bookstore element into a variable called $x.The where clause selects
only book elements with a price element with a value greater than 30.The order by clause defines
the sort-order. Will be sort by the title element.The return clause specifies what should be
returned. Here it returns the title elements.
Example: doc("books.xml")/bookstore/book[price>30]/title
The following FLWOR expression will select exactly the same as the path expression
above:
for $x in doc("books.xml")/bookstore/book where $x/price>30 return $x/title
The result will be:
<title lang="en">XQuery Kick Start</title>
<title lang="en">Learning XML</title>
With FLWOR you can sort the result:
for $x in doc("books.xml")/bookstore/book where $x/price>30 order by $x/title return
$x/title
Source : http://nprcet.org/e%20content/Misc/e-Learning/IT/VIII%20Sem/IT1451%20-%
20XML%20and%20Web%20Services.pdf