Introduction | XML Data Setup | XSL and XSLT | XPath | Conclusion
XML - A database you can build for yourself out of rocks and twigs.
Okay,
you can't do it with rocks and twigs, but you can do it with the computer
equivalent - plain text. The (ASCII) standard for exchange of words in most
European, and some non-European, alphabets has been around long enough for
us to be able to rely on it to be here long after the latest techno-gizmo
has ended up trash-heaped.
XML stands for "eXtensible Markup Language," and what people often say about it is "You get to make up your own tags." Actually, what you get to make up are like the names of fields in the records of a database. Some modern browsers (IE6 and Mozilla 1) with XML support will display the data reasonably attractively, and if you attach an XSL (eXtensible Stylesheet Language) file, you can even get those browsers to display a web page.
Examples
Here is an XML file. Be sure to view this using
IE 6 or Mozilla; otherwise, all the data will run together on the web page.
Be sure to View the Source.
Here is is with an XSL file attached. Be sure to View the Source here too. (The only difference is line 2.)
Here is the XSL file. If you are using IE6 or Mozilla, you can click on the minus signs (-) to collapse the structure. You will see that this resembles an ordinary HTML document, except for a section of the body which has this:
<xsl:for-each select="/Curriculum/Class">
<tr>
<td valign="top" class="plaintext">
<xsl:value-of select="Teacher" />
</td>
<td valign="top" class="plaintext">
<xsl:value-of select="ClassName" />
</td>
<td valign="top" class="plaintext">
<xsl:value-of select="Duration" />
Days
</td>
</tr>
</xsl:for-each>
This is how XSL and the browser generate the table showing the teachers and classes. The database is named "Curriculum," and the three fields are called Teacher, ClassName, and Duration. The browser loops through ("for-each") the whole database, and displays the specified values it finds. The HTML code, with some help from Cascading Style Sheets(CSS), surrounds the instructions for locating the data, and transforms the XML file into a recognizable web page!
Additionally, this plain-text database can be paired with other XSL stylesheets to transform it for audio display, for wireless devices, for pdf files, for braille writers - in short, for most of the display methods we've already thought of. The whole idea of XML is to create such simple building blocks (think LEGO) that they can be easily transformed for display on all devices - including those we haven't thought of yet!
To understand XML for the web, you need to understand
- XML - setting up the data
- XSL and XSLT - transforming the data
- XPath - searching, selecting, and sorting the data
Glossary
The "X" in XML, XSL and XPath stands for "eXtensible"
because these technologies are designed to be extended into new applications.
XML -- eXtensible Markup Language
XSL -- eXtensible Stylesheet Language
XSLT-- eXtensible Stylesheet Language Transformations
XPath -- XML Path
There are other "X" technologies that bear looking into, as well, but we'll stick to these for now.
Observable XML
A lot of XML is used behind the scenes, in large corporations and government agencies, but raw XML "feeds" are showing up on news sites, including blogs.
RSS feeds
- Computerworld: http://www.computerworld.com/news/xml/index/
- New York Times: http://www.nytimes.com/services/xml/rss/index.htm