Ic Units 3

Download as pdf or txt
Download as pdf or txt
You are on page 1of 23

UNIT- III

XML TECHNOLOGY FAMILY

The Role of XML


XML is a specification for defining new markup languages.
XML is a metalanguage (literally a language about languages) defined by the World Wide Web
Consortium (W3C), one of the main organizations driving the push to open Web standards. In its
simplest sense, XML is a set of rules and guidelines for describing structured data in plain text
rather than proprietary binary representations. However, as a phenomenon, XML goes beyond its
technical specification. Since its standardization by the W3C in 1998, XML has been the driving
force behind numerous other standards and vocabularies that are forging a fundamental change
in the software world.
k /
XML is simple. Technically, it's a language for creating other languages based on the

.
what we mean by this, let's begin with a simple XML data description.
t
insertion of tags to help describe data. However, XML is actually more than just tags. To see

e
XML is a combination of tags and content in which the tags add meaning to the content.
b
t u
The following is a simple XML markup of customer information. Start tags such as <Name>
begin an element that contains the actual data. End tags such as </Name> mark the end of an
element definition.
<Customer>
s e
<Name>John von Neumann</Name>
<PhoneNum>914.631.7722</PhoneNum> / c
:
<FaxNum>914.631.7723</FaxNum> /
</Customer>
t p
<E-Mail>Johnny@cd.com</E-Mail>

h t
There are several important basic points to observe about these definitions.
XML allows data to be stored in either elements or attributes.
Elements and attributes can be named to give the data meaning.
Start tags and end tags define elements that are the basis for XML tree-structured
representations of documents.
Elements can contain text data and/or other elements.

The XML Advantage

XML has had an impact across a broad range of areas. The following is a list of some of the
factors that have influenced XML's adoption by a variety of organizations and individuals.
XML files are human-readable. XML was designed as text so that, in the worst case,
someone can always read it to figure out the content. Such is not the case with binary data
formats.
Widespread industry support exists for XML. Numerous tools and utilities are being
provided with Web browsers, databases, and operating systems, making it easier and less

http://csetube.weebly.com/
expensive for small and medium-sized organizations to import and export data in XML
format.
Major relational databases now have the native capability to read and generate XML data.
A large family of XML support technologies is available for the interpretation and
transformation of XML data for Web page display and report generation.

The XML Technology Family


XML is not just a technology for defining data vocabularies. Surrounding XML is a wide
variety of XML standards and initiatives that act in combination with XML to address many of
the issues associated with bringing XML into mainstream computing, namely presentation,
structure, and transformation. As fig shows, the XML core includes XML itself, based on the
XML 1.0 specification, and namespaces, the specification that allows XML documents from
different sources to be combined and yet be able to disambiguate elements with the same
name from different sources. Following is a list of other categories in the XML technology:

/
Structure and data types: When using XML to exchange data among clients, partners, and
k
suppliers, it's important to be able to define how XML documents should be structured.

. t
DTDs and XML Schema provide this capability. DTDs come out of the world of

b e
Standard Generalized Markup Language (SGML), focusing primarily on structure by
specifying what elements and attributes are considered valid for a particular XML


instance document.
t u
XML Schema is a more recent initiative of the World Wide Web Consortium (W3C) that

precision than with DTDs. s e


puts a more conventional data processing spin on describing XML data with more


/ c
XML presentation technologies: In keeping with an important design pattern for robust

: /
systems, XML intentionally separates data content from presentation through the
introduction of supporting technologies that focus on delivering content to users via a

t p
variety of devices and presentation media. Among the technologies for presentation are
XHTML, a modular XML-conformant replacement for HTML; CSS for controlling the

h t
display properties of HTML or XML in Web browsers; XSL and XSL Formatting
Objects (XSL-FO) for formatting XML for various output media; XForms for collecting
data from Web forms and returning XML; VoiceXML, for delivering content to voice-
enabled devices; and Wireless Markup Language (WML), for delivery to wireless
devices enabled for Wireless Application Protocol (WAP).
XML manipulation technologies: Manipulation technologies provide the capability to
extract and transform XML in different ways. These technologies play an important role
in server-based XML processing for business-to-business (B2B) data manipulation and
exchange. XSLT is widely used to transform XML from one format to another; XPath is
a technology used by other XML technologies to navigate through an XML tree structure
and zero in on particular elements or subtrees; XLink is a technology for creating and
describing links between resources and for enabling links that go beyond the simple
unidirectional links of the current Web; and XQuery is an evolving technology for
extracting and querying XML repositories.

http://csetube.weebly.com/
Other related technologies: The XML family of technologies also includes initiatives for
working with metainformation, which is literally information about the information
contained in an XML document. Technologies in this space include RDF and InfoSet.

The XML technology family.

k /
. t
b e
t u
s e
/ c
Structuring with Schemas
: /
A schema defines a data representation.

t p
"Schema" is a general term that describes the form of data. Originally the term was used
to define the structure of databases. A schema is a formal specification of the grammar for a

h t
specific XML vocabulary. Schemas are useful in validating XML document content, determining
whether the XML document conforms to the grammar expressed by the XML Schema, and
describing XML structure to others, which enables the exchange of structured information
between collaborating applications or business partners in a platform- and middleware-neutral
manner.

In the XML world, there are two schemas: DTDs and XML Schemas.

Figure illustrates how either may be used to define a family of XML document instances. DTDs
focus primarily on structure, allowing an XML vocabulary designer to specify the elements and
attributes that are appropriate for a set of XML instance documents. However, DTDs have
limited capability to describe data types within an XML document.

Both DTDs and XML Schemas may be used to define the structure of an XML
document.

http://csetube.weebly.com/
k /
. t
b e
u
XML Schema is a newer technology, adopted by W3C as an official Recommendation in
t
s e
May 2001, intended to provide the kind of detailed structure often associated with programming
languages' data types and useful in enabling solutions for the exchange of XML-based
c
information where it is helpful to check data format accuracy before processing begins.
/
DTD:
: /
t p
DTD can be used by both the sender and receiver of a ZwiftBooks document. When

h t
ZwiftBooks publishes its DTD for a query, senders can use the DTD to create XML documents
that the ZwiftBooks server will understand. On the receiving end, the server can compare an
incoming XML document against the DTD and determine if the incoming XML data is valid
with respect to the DTD. If not, it can return a message indicating an error in the incoming data
format.

http://csetube.weebly.com/
k /
. t
b e
t u
s e
/ c
: /
t p
Figure shows how a DTD can be used by both the sender and receiver of a ZwiftBooks
document. When ZwiftBooks publishes its DTD for a query, senders can use the DTD to create

h t
XML documents that the ZwiftBooks server will understand. On the receiving end, the server
can compare an incoming XML document against the DTD and determine if the incoming XML
data is valid with respect to the DTD. If not, it can return a message indicating an error in the
incoming data format.
. There are several points to keep in mind:
DTDs are written using a different syntax from XML. This is because DTDs were first
developed in the SGML world before XML existed.
DTDs define the elements and attributes that can validly appear in our ZwiftBooks XML
documents.
DTDs are not able to define distinctions about data types. For example, a DTD cannot
declare that an element must contain a valid date or numeric field or even an ISBN
number. A DTD is limited to declaring that an element must contain text; it cannot
control what kind of text, as, for example, by distinguishing between numeric and
alphabetic characters.

http://csetube.weebly.com/
XML Schema
The alternative to using DTDs to specify what constitutes a valid ZwiftBooks XML
document is to use XML Schemas. The XML Schema Recommendation goes beyond the basic
text-based descriptors provided by DTDs. It provides more detail about the kind of data that can
appear as part of an XML document. Unlike the non-XML syntax of a DTD, XML Schema is
itself an XML vocabulary that defines rules governing the structure and content of elements and
attributes in an XML document. Because XML Schemas are XML, they can be processed and
managed like any XML instance.

XML Schemas take a giant step in moving XML from the document world into the data
processing world. Schemas support a broad range of data types, and include useful features like
range constraints that let XML authors describe bounds for data that can be enforced by schema
processors. The advantage of using XML Schemas over DTDs is that XML Schemas eliminate
the need for hand-coded data checking of XML data fields. Off-the-shelf software can validate
XML data against a broad range of built-in data types.

k /
As Figure illustrates, XML Schema data types form a hierarchy. All data types derive, directly or
indirectly, from the root anyType, which can be used to indicate any value at all. Below

. t
anyType, the hierarchy branches into two groups consisting of simple types and complex types.

XML Schema data types


b e
t u
s e
/ c
: /
t p
h t

http://csetube.weebly.com/
k /
. t
b e
t u
s e
/ c
Complex Types
: /
t p
Complex types can be used to model application-specific data.

h t
Complex types are an important aspect of XML Schema that allow application
developers to define application-specific data types that can be checked by programs that check
XML documents for validity. As Figure 2.8 shows, XML Schema divides complex types into
two categories: those with simple content and those with complex content. Both varieties allow
attributes, but simple content types can contain only characters, whereas complex content types
can contain child elements.
A ZwiftBooks schema to describe the data associated with a book.

http://csetube.weebly.com/
k /
. t
b e
t u
s e
/ c
: /
t p
h t

Schemas in Practice
Schemas provide a flexible and rich language to specify, package, publish, and exchange
both structured and unstructured information across application or business boundaries. Schemas
may be used in several ways with XML documents. Through use of the xsi:type attribute, an
element can explicitly assert its type within a specific XML document instance. Such assertions
can be used to validate an element against a predefined XSL type. To handle versioning and
time-related processing, the XML Schema type timeInstant may be used to specify a particular
instant of time. Values for timeInstant are compliant with the ISO 8601 time and date standard.
The XML Schema uriReference data type can handle links to URIs, which may be specified
using an absolute or relative syntax.

http://csetube.weebly.com/
XML Processing
When XML arrives at a server, it is typically validated against a DTD or XML Schema
and then stored, transformed, or processed in some way depending on the application. Both
validation and processing can be performed by XML parsers. In the XML parsing and processing
world there are two major alternatives: the Document Object Model (DOM) and the Simple API
for XML (SAX).

DOM
DOM is a W3C-supported standard application programming interface (API) that
provides a platform- and language-neutral interface to allow developers to programmatically
access and modify the content and structure of tree-structured documents such as HTML or
XML. Because DOM is language neutral, programmers can use scripting languages or
programming languages such as Java to process XML.
/
DOM is constantly evolving to keep up with changes in the XML world. It includes the
k
. t
following levels, each of which provides more capability to the DOM API:
DOM Level 0 informally refers to the functionality available to scripting languages in

specification for Level 0.


b e
Netscape Navigator 3.0 and Microsoft Internet Explorer 3.0. There is no W3C

support for XML 1.0 and HTML processing. t u


DOM Level 1 is a W3C Recommendation completed in October 1998. Level 1 provides

e
DOM Level 2 is a W3C Recommendation completed in November 2000. Level 2 extends
s
/ c
Level 1 with support for XML 1.0 with namespaces and CSS. It also provides support for
user interface and tree manipulation events and adds additional DOM tree manipulation
capabilities.
: /
DOM Level 3 is still under development as of this writing. Level 3 is intended to extend

t
Schema, and XPath.
p
Level 2 by adding user interface keyboard events. It will also support DTDs, XML

h t
DOM falls under the category of tree-based APIs which are useful for a wide range of
applications but can strain system resources when documents are large. Also, because DOM is
language neutral, processing in a strongly typed language such as Java can introduce unwanted
complexities when going from DOM interfaces to language-specific data structures. To
overcome these drawbacks, developers began to look at event-based processing models that
reduced system memory requirements and let developers create their own data structures. The
result was SAX.

SAX
SAX is an example of a grass-roots development effort to provide a simple, Java-based
API for processing XML. It began with design discussions taking place publicly on the XML-
DEV mailing list. One month after discussions began, the first draft interface was released in
January 1998. After further mailing list discussion, SAX 1.0 was released.

http://csetube.weebly.com/
SAX differs from DOM in that SAX is event-driven. Programmers define event handlers
that are notified when elements are found in an XML document. The handler code uses the
information delivered by SAX to perform application-specific processing tasks.
SAX2 was released in May 2000 and provides support for other languages besides Java.
SAX2 also supports filter chains that may be used to construct event processing pipelines. Filter
chains are useful in building complex XML applications that can be partitioned into tasks
modeled as simple SAX components. In a SAX filter chain, each SAX component does some
processing and passes data on to the next SAX component in the chain.
While SAX is simple, there is a downside. Programmers working with SAX must build
their own data structures to help keep track of where they are in a document. In effect, they have
to maintain state as they process XML using SAX. This can make programs complex and more
difficult to maintain. Thus it's important that developers understand both SAX and DOM and
choose their API based on the requirements of the application.

Presentation Technologies

k /
Representing data with XML opens up new possibilities for transport and distribution.
XML presentation technologies provide a modular way to deliver and display content to a variety

. t
of devices. Here we examine some technologies for display, including CSS, XSL, Xforms, and
VoiceXML.
b e
CSS
t u
s e
Cascading style sheets is an XML-supporting technology for adding style display
properties such as fonts, colors, or spacing to Web documents. CSS origins may be traced to the

/ c
SGML world, which used a style sheet technology called DSSSL to control the display of SGML
documents. Style sheet technology is important because it lets developers separate presentation

: /
from content, which greatly enhances software's longevity.
A Style sheet tells a browser or other display engine how to display content. Each rule is made
p
up of a selectortypically an element name such as an HTML heading (H1) or paragraph (P), or
t
h t
a user-defined XML element (Book)and the style to be applied to the selector. The CSS
specification defines numerous properties (color, font style, point size, and so on) that may be
defined for an element. Each property takes a value which describes how the selector should be
presented.

HTML or XML may be delivered to a browser with CSS, which controls how data is
presented on the screen.

http://csetube.weebly.com/
Style rules have the following syntax.
selector { property: value }
Multiple style declarations for a single selector are separated by a semicolon. The
following code segment shows how a CSS element can be added to an HTML or XML document

k
to define the color and font size properties for TITLE and AUTHOR elements: /
<STYLE TYPE="text/css">
. t
TITLE { font-size: x-large; color: red }
AUTHOR { font-size: large; color: blue } b e
</STYLE>
t u
s e
This style sheet tells the browser to show the content of TITLE elements in an extra-large

/ c
red font, and to show the content of AUTHOR elements in a large blue font. Although CSS
technology was designed to allow finer control of how HTML is displayed, CSS makes no

with XML as with HTML. : /


assumptions about the tags' names, which is why cascading style sheets can be used just as easily

p
Because style sheet technology is important for the Web design industry, the CSS
t
h t
specification has undergone significant evolution. The CSS1 specification, which defines all
properties and values that can be applied to a Web document, received its W3C
Recommendation status in December 1996. It describes the CSS language as well as a simple
visual formatting model.
However, there are two drawbacks with CSS that should be noted. The first is that CSS
describes only those tags that are to be treated in a special way; the browser decides how to
display elements that the style sheet says nothing about. While this typically works fine for
HTML, with XML, where it may be desirable not to display certain data, CSS does not help. The
second drawback is that with CSS technology it is up to the browser to implement CSS correctly,
and some implementations may not always be consistent.

XSL
XSL 1.0 is a W3C Recommendation that provides users with the ability to describe how
XML data and documents are to be formatted. XSL does this by defining "formatting objects,"
such as footnotes, headers, or columns.

http://csetube.weebly.com/
The XSL initiative began as an effort to develop a styling technology more suited to the
needs of XML than CSS. However, in pulling together a Working Group to define XSL,
something interesting happened. The Working Group realized that the kind of styling per formed
by technologies such as CSS was only one instance of a more general transformation process of
taking an XML document and turning it into another kind of document. After much deliberation
the XSL Working Group split into two subgroups, one focused on trying to build a better
display-oriented style sheet technology and a second group trying to define a transformation
language that could be used to transform XML into a variety of target languages including
HTML, other dialects of XML, or any text document, including a program.
An XSL style sheet is basically a series of pattern-action rules and looks like an XML
document with a mixture of two kinds of elements: those defined by XSL and those defined by
the object language. The patterns are similar to CSS's selectors, but the action part may create an
arbitrary number of "objects." The action part of the rule is called the "template" in XSL, and a
template and a pattern together are referred to as a "template rule."
The result of applying all matching patterns to a document recursively is a tree of objects,
which is then interpreted top-down according to the definition of each object. For example, if

will be the result. k /


they are HTML objects, an HTML document will be generated; if they are XML objects, XML

. t
CSS Compared to XSL
b e
t
CSS
u XSL
Can be used with HTML?
s eyes no
Can be used with XML?
/ c yes yes

:/
Transformation language? no yes
Syntax CSS XML

t p
h t
Options for using CSS and XSLT with XML and HTML

http://csetube.weebly.com/
k /
. t
XFORMS
b e
t u
XForms is an XML approach that overcomes the limitations of HTML forms. XForms is

s e
a GUI toolkit for creating user interfaces and delivering the results in XML. Because XForms
separates what the form does from how it looks, XForms can work with a variety of standard or

/ c
proprietary user interfaces, providing a standard set of visual controls that replaces the primitive

: /
forms controls in HTML and XHTML. Included in XForms are a variety of buttons, scrollbars,
and menus integrated into a single execution model that generates XML form data as output.

t p
XForms provides a standard way to collect form data through a variety of device
interfaces.
h t

http://csetube.weebly.com/
k /
. t
b e
There are currently several XForms implementations:
t u
s e
X-Smiles is a Java-based XML browser from Helsinki University of Technology. It
implements a large part of XForms and uses XForms together with XSL-FO on the user

/
1.0, and Scalable Vector Graphics.
c
interface side. It also supports XSLT, Synchronized Multimedia Integration Language

/
Mozquito XForms Preview is an XML-based Web development software that
:
t p
implements XForms and gives current Web browsers the ability to send, receive, and
process XML data easily and effectively. It reads and writes XML instances without the
need for XSL.
h t
XHTML

XHTML is an effort by the W3C to replace HTML with a more flexible approach to
displaying Web content. XHTML differs from HTML in that it is based on XML, not SGML.
Thus, XHTML conforms to the XML 1.0 Recommendation. The long-term goal of the XHTML
spec is that XHTML will continue to be useful in environments where there are no preconceived
notions about how elements should be rendered in a browser. The approach is one in which
developers will be able to extend in unanticipated ways as new technologies and display media
emerge. Its modular design reflects the realization that a one-size-fits-all approach to the Web no
longer works, especially when browsers differ significantly and cell phones have limited
memory and screen size for display.

XHTML Modularization

http://csetube.weebly.com/
The capability of XHTML to be more flexible than HTML is attributable to the use of
XHTML modules for creating XHTML-conforming markup languages. New XHTML-compliant
languages must use the basic XHTML framework as well as other XHTML modules. the
modules plug together within the XHTML framework to define a markup language that is task or
client specific. Documents developed based on the new markup language will be usable on any
XHTML-conforming clients.

The structure of XHTML.

k /
. t
b e
t u
s e
/ c
: /
t p
h t
In some instances, people will create complete, proprietary markup languages using
XHTML. People may also create new, reusable modules that will find use within their own or
other organizations. The architecture and technology behind XHTML are already finding use
within the W3C by organizations such as the Organization for the Advancement of Structured
Information Standards (OASIS) and Project Gutenberg, which are using XHTML modularization
to create new markup languages for industry-specific applications. XHTML is also finding
applicability within the wireless industry that sees it as the next-generation language of choice
for NTT DoCoMo's i-mode cell phones and as the WAP Forum's replacement technology for
WML.

VoiceXML

http://csetube.weebly.com/
VoiceXML is an emerging standard for speech-enabled applications. Its XML syntax
defines elements to control a sequence of interaction dialogs between a user and an
implementation platform. The elements defined as part of VoiceXML control dialogs and rules
for presenting information to and extracting information from an end-user using speech. For
ZwiftBooks, VoiceXML opens up options for extending its service to voice through cellular
networks.
VoiceXML documents are stored on Web servers. Translation from text to voice is
carried out either on a specialized server that delivers voice directly to a phone or by the device
itself using speech processing technology.

VoiceXML documents are used to drive voice interactions over conventional or


wireless phones.

k /
. t
b e
t u
s e
/ c
: /
t p
h t

Just as a Web browser interprets HTML and displays it on the screen, a VoiceXML
browser understands VoiceXML markup and interprets it for presentation over the telephone or
directly to an audio channel. As mobile devices such as cell phones acquire additional processing
power, it will be possible to deliver VoiceXML documents directly to cell phones for VoiceXML
processing.
The VoiceXML document specifies each interaction dialog. User input affects dialog
interpretation and is collected into requests that go back to the VoiceXML server. The server
may reply with another VoiceXML document to continue the user's session with other dialogs.
A VoiceXML document includes tags defining both audio prompts and logic. For
example, the content of a prompt tag is converted by a VoiceXML browser to speech. Other

http://csetube.weebly.com/
VoiceXML tags include form for building a voice-driven form to collect user information and
menu, which leads an end-user through a series of menu selections.

Forms and Menus

There are two kinds of dialogs: forms and menus. Forms define an interaction that
collects values for a group of fields. Each field may specify a grammar that controls the
allowable inputs for that field. Menus present the user with a choice of options and then
transition to another dialog based on that choice.
Forms also contain subdialogs that provide a mechanism for triggering a new interaction
and returning to the original form. Subdialogs can be used to create a confirmation sequence that
may require a database query, a set of components for sharing among documents in a single
application, or a reusable library of dialogs shared across many applications.

Transformation

k /
XML is supported by several technologies that allow XML to be manipulated and
modified in various ways. These technologies include XSLT, XLink, XPath,and XQuery.

. t
XSLT
b e
t u
XSLT is an XML-based language used to transform XML documents into other formats
such as HTML for Web display, WML for display on WAP devices, alternate XML dialects for
B2B data transfer, or just plain text.
s e
/ c
To perform an XSL transformation, a program referred to as an XSLT processor reads

: /
both an XML document and an XSLT document that defines how to transform the XML. An
XSLT processor has the capability to read the XML source document, and rearrange and
p
reassemble it in a variety of ways, even adding new text and tags.
t
h t
The transformation language XSLT may be used to transform XML into a variety of formats.

http://csetube.weebly.com/
k /
. t
b e
t u
The XSLT Model s e
/ c
: /
t p
Writing XSLT is different from writing a program that specifies in a step-by-step manner
what a processor is expected to do. XSLT transformations occur through a series of tests that

h t
compare parts of an XML document against templates defined in an XSLT document. Templates
act like rules that are matched against the contents of a document; when a match occurs,
whatever the template specifies is output. For example, assume an XML document contains the
fragment

<title> A History of PI </title>

Given a template that matches for a title element

<xsl:template match="title">
<H2>
<xsl:value-of/>
</H2>
</xsl:template>

the output will be

http://csetube.weebly.com/
<H2> A History of PI </H2>

where the <xsl:value-of/> tag is replaced by the actual value of the title element. Using this
capability, one can go from XML to HTML or other forms of XML.

The following is a complete style sheet that generates a Web page of all books in an XML
document:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>

<xsl:template match="books">
<html>
<head>
<title>ZwiftBooks At Your Doorstep</title>
k /
</head>
<body>
. t
<h2>Weekly Specials</h2>

b e
<xsl:apply-templates/>

t u
</body>
</html>
</xsl:template> s e
<xsl:template match="book"> / c
: /
<p></p><b>Title:</b> <xsl:value-of select="title/><br/>
<em>Author:</em> <xsl:value-of select="author"/>
p
<em>ISBN:</em> <xsl:value-of select="isbn"/>
t
</xsl:template>
h t
<xsl:apply-templates/>

</xsl:stylesheet>

Let's look at a portion of this page in a bit more detail.

<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>

The slash in the first line tells the processor that this node applies to the root level of the XML
document. Think of the root level as an imaginary pair of tags surrounding the entirety of an
XML document which must be addressed before you can get to the actual tags. The apply-
templates tag tells the processor to look at everything that occurs beneath the current level; in
this case it means, "examine everything." This command can be found in most XSLT documents.

http://csetube.weebly.com/
In our example note that there are two templates: one that matches for books and another
that matches for a book. When a books element is found, the outer structure of an HTML page is
printed. Within the books template there is another apply-templates element which says to
keep trying to find more matches in the XML document. When the XSLT matches a book
element, the book template is activated and details of the book are printed as HTML.

The syntax for XSLT is quite involved and there is a significant learning curve associated with
becoming competent at using it to transform documents. In keeping with the W3C spirit of
simplicity and combination, XSLT uses XPath as the language for zeroing in on elements within
an XML tree. XSLT also provides "if-then" and "choose" functions for embedding program logic
into an XSLT style sheet. Such features allow a wide range of manipulation for XML content.

XSLT and CSS

/
Both XSLT and CSS may be used to generate data for display, either alone or in
k
. t
combination.There are a variety of options for using the two technologies. For example, when
beginning with HTML, one can generate a display by going directly to a browser (Option 1) or

b e
by using CSS to control how the HTML is displayed (Option 2). When beginning with XML,
one may use CSS to generate display (Option 3) or use XSLT to generate HTML (Option 4). It's

t u
also possible to go from XML to another form of XML and then use CSS to control the display
(Option 5). Another option is to use XSLT to generate an XML Formatting Object (Option 6)
and then use CSS to generate display.
s e
/ c
XSL-FO is the formatting part of XSL, an XML-based markup language that allows fine

: /
control of display, including pagination, layout, and style. Because XSL-FO markup is fairly
complex and verbose, it is recommended that XSLT be used to actually generate an XSL-FO

t p
source document. As a result of the current paucity of tools that support XSL-FO, it is not nearly
as widely used as XSLT, or XSLT with CSS.

XLink h t
The notion of resources is universal to the World Wide Web. According to the Internet
Engineering Task Force, a "resource" is any addressable unit of information or service. Examples
include files, images, documents, programs, and query results. These resources are addressed
using a URI reference. What XLink brings to the table is the ability to address a portion of a
resource. For example, if the entire resource is an XML document, a useful portion of that
resource might be a single element within the document. Following an XLink might result, for
example, in highlighting that element or taking the user directly to that point in the document.

XPath

XPath gets its name from its use of a path notation to navigate through the hierarchical
tree structure of an XML document. Because all XML documents can be represented as a tree of
nodes, XPath allows for the selection of a node or group of nodes through the use of a compact,

http://csetube.weebly.com/
non-XML syntax. It is an important XML technology due to its role in providing a common
syntax and semantics for functionality in both XSLT and XPointer.

XPath operates on the hierarchical tree structure of an XML document rather than its tag-based
syntax. It is capable of distinguishing between different types of nodes, including element nodes,
attribute nodes, and text node.

XPath is used to specify nodes using their location in an XML tree.

k /
. t
b e
t u
s e
/ c
: /
t p
h t

XQuery

XQuery is a W3C initiative to define a standard set of constructs for querying and
searching XML documents. The XML Query Working Group draws its membership from both
the document and the database communities, trying to hammer out an agreement on XML-based
query syntax that meets the needs of both cultures.

http://csetube.weebly.com/
Although the final form of the XQuery language is still open to definition as of this
writing, the Working Group has published a set of queries in the form of use cases, which the
final draft of the XQuery specification is expected to address. Although it's too early to
implement for XQuery, ZwiftBooks can strategically look ahead to see if it can leverage any of
the immediate functionality provided by emerging XQuery examples.

For example, selection and extraction are fundamental database operations. A typical
select-and-extract operation is to select all titles of books in the ZwiftBooks catalog published by
Addison-Wesley after 1993. The result, in XML, might look like this:

<books>
<book year="1994">
<title>Object Oriented Programming</title>
</book>
<book year="1994">
<title>Design Patterns for Object-Oriented Software
Development</title>
</book>
</books>
k /
The following is how extraction of this data might look in XQuery:
. t
<books>
b e
{

t
FOR $b IN document("http://www.zwiftbooks.com")/bib/book u
RETURN
s e
WHERE $b/publisher = "Addison-Wesley" AND $b/@year > 1993

<book year={ $b/@year } >


{ $b/title }
/ c
</book>
}
</books> : /
t p
h t
In this example, note how XML tags are interspersed with XQuery code embedded
between open and close curly brackets. In the following sections we examine other examples of
some of the functionality that ZwiftBooks may expect from XQuery.

Flattening

This function creates a new flattened list of all the title-author pairs, with each pair
enclosed in a new result element. The expected result is

<results>
<result>
<title>Object Oriented Programming</title>
<author>
<last>Cox</last>
<first>Brad</first>
</author>
</result>
<result>
<title>Object-Oriented Design Heuristics</title>

http://csetube.weebly.com/
<author>
<last>Riel</last>
<first>Arthur</first>
</author>
</result>
<result>
<title>A History of PI</title>
<author>
<last>Beckman</last>
<first>Petr</first>
</author>
</result>
</results>

Changing Structure by Nesting

Often the result of a query will need to have a structure different from the original XML
document. XQuery supports restructuring an XML document. Thus it is possible to create a new

k /
XML document that groups each author with that author's titles. This requires the equivalent of a
relational database join that creates a new element out of existing elements.

Changing Structure by Explicit Grouping


. t
b e
Combining information from different parts of a document is useful when merging

t u
information from multiple sources. For example, a second data source from a site such as
www.bookreviews.com/reviews.xml may contain book reviews and prices organized in a

s e
completely different way from the ZwiftBooks site. XQuery will allow creating a query that

c
searches both documents and lists all books with their prices from both sources.
/
Sorting

: /
t p
In our earlier example, all titles of books published by Addison-Wesley after 1993 were
generated in no specific order. XQuery will support the sorting of query results using any
t
combination of elements so that, for example, titles may be listed alphabetically.
h
Tag Variables

XML documents do not always come with a DTD. Therefore provision must be made to
query documents without knowledge of structure or tag names. To handle this situation, XQuery
supports queries that match element tags based on a regular expression or on phrases. For
example, it is possible to match against an element that contains the text "author" or "editor" and
whose value is "Jones" by building such a query directly into the XQuery.

http://csetube.weebly.com/

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy