Information Technology Reference
In-Depth Information
human-consumable information towards machine-readability. These issues are
partly being addressed by XPath and XSLT.
XPath is a lightweight query language for extracting parts of XML trees.
It allows to specify complex conditions on child or parent nodes, content,
or attribute values, and provides simple arithmetic and aggregation (such as
summing or averaging element values). The details of XPath are beyond the
scope of this topic, but, most importantly, XPath is one of the main com-
ponents of Extensible Stylesheet Language Transformations (XSLT) which
allows one to rearrange and synthesize the results of XPath queries into new
XML documents; thus, the transformation of an arbitrary XML format into
another one is facilitated.
Here also, we do not want to go into details, but it is worth noting the evi-
dent concepts behind XSLT (Fig. 2.6). An XSLT stylesheet defines templates
which match certain parts of the original XML file(s) and convert them into
the output format. These templates can be recursively applied or explicitly
called.
The example in Fig. 2.6 shows an XML stylesheet which converts our
running example XML file back to XHTML, which can be displayed in your
Web browser.
Again, we emphasize that XSLT is not restricted to XHTML transforma-
tions but can also be used for arbitrary conversions between different XML
formats.
2.3.4 Applications and Tools for XML
In this subsection, we discuss, without claiming to be exhaustive, some avail-
able tools and applications for XML, illustrating the great success of XML in
the past few years. Application designers and developers are profiting from
the large number of available APIs and tools for XML.
To o l s
As shown in Fig. 2.5 XML documents are often conceived as trees. Application
programming interfaces (APIs) for XML such as DOM 9 -based APIs indeed
store XML documents in a tree-like data structure while parsing and allow
programmers to conveniently deal with XML data in the DOM tree in memory,
navigating between child and parent elements, along attributes, etc. Such an
in-memory representation of XML data might become too inflexible or space-
consuming for large XML documents. Therefore other more lightweight APIs,
such as SAX, 10 have been developed in order to parse and process XML files
sequentially using an event-based model.
9 http://www.w3.org/DOM .
10 http://www.saxproject.org .
Search WWH ::




Custom Search