The beauty of XML is that it allows for easy data exchange. We can even change the presentation format of the data through XSLT transformation. It is relatively easy to move from one format to another.
XML can be changed or "transformed" into something else: pdf, postscript, SGML, HTML, or a different XML format. The xml data can become web pages, book chapters, reports, or searchable databases. A transformation program can be written to create any style and format others would need.
For instance, we transform the XML files into HTML so they can be displayed on the web. Here we have done a very quick transformation, but it can get much fancier.
To convert the xml files into html, we used an XSLT tranformation "script".
XSLT is very much like HTML. It looks much harder than it really is. Once you understand the structure, you are well on your way to creating any presentational look and feel you want.
The raw data looks like this:
<?xml version = "1.0" encoding = "UTF-8"?>
<!DOCTYPE Plant_Description SYSTEM "http://www.isrl.uiuc.edu/~openkey/shared/Plant_Description_2_20.dtd">
<Plant_Description>
<taxon>
<Rank>species</Rank>
<Name>Acer barbatum</Name>
<Authority>Michx.</Authority>
<ITIS_Taxonomic_Serial_Number>28759</ITIS_Taxonomic_Serial_Number>
<Synonym> <Name>Acer barbatum var. longii</Name>
<Authority>(Fern.) Fern.</Authority>
</Synonym>
<Synonym>
<Name>Acer barbatum var. villipes</Name>
<Authority>(Rehd.) Ashe</Authority>
</Synonym> <Synonym>
<Name>Acer floridanum</Name>
<Authority>(Chapman) Pax</Authority>
</Synonym>
<Synonym>
<Name>Acer floridanum var. longii</Name>
<Authority>Fern.</Authority>
</Synonym>
<Synonym>
<Name>Acer floridanum var. villipes</Name>
<Authority>Rehd.</Authority>
</Synonym>
<Synonym>
<Name>Acer nigrum var. floridanum</Name>
<Authority>(Chapman) Fosberg</Authority>
</Synonym>
<Synonym>
<Name>Acer saccharinum var. floridanum</Name>
<Authority>Chapman</Authority>
</Synonym>
<Synonym>
<Name>Acer saccharum var. floridanum</Name>
<Authority>(Chapman) Small & Heller</Authority>
</Synonym>
<Synonym>
<Name>Acer saccharum ssp. floridanum</Name>
<Authority>(Chapman) Desmarais</Authority>
</Synonym>
<Synonym>
...and much much more
The XSLT creates the HTML page that looks like this:
The xslt for the long Plant Description xml files we have looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:strip-space elements="*"/>
<xsl:output method="html"
encoding="UTF-8"
doctype-public="-//W3C//DTD HTML 4.01//EN"
doctype-system="http://www.w3.org/TR/html4/strict.dtd"
indent="yes"/>
<xsl:template match="/">
<html>
<head>
<title>XML records</title>
<style type="text/css">
body { background-color: white }
</style>
</head>
<body>
<!-- In this program, note that the difference between child::node() and child::*, also the program is required to\
display the deepest node's context, while not the parent node, Jing :) 4/26/03 -->
<xsl:for-each select="child::Plant_Description">
<h1>Name</h1>
<xsl:for-each select="child::taxon">
<xsl:for-each select="child::*">
<!--here for those tags appear only once -->
<xsl:if test="name()!='Synonym' and 'Vernacular'">
<b><xsl:value-of select="name()"/>: </b>
<xsl:value-of select="child::text()"/> <xsl:text> </xsl:text>
</xsl:if>
</xsl:for-each>
<p/>
<!--deal with Synonym-->
<b>Synonym: </b>
<xsl:for-each select="child::*">
<xsl:if test="name()='Synonym'">
<xsl:for-each select="child::*">
<b><xsl:value-of select="name()"/>: </b>
<xsl:value-of select="child::text()"/> <xsl:text> </xsl:text>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
<p/>
<!--deal with Vernacular-->
<b>Vernacular: </b>
<xsl:for-each select="child::*">
<xsl:if test="name()='Vernacular'">
<xsl:value-of select="child::text()"/> <xsl:text>, </xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
<!--description-->
<xsl:for-each select="child::*">
<xsl:if test="name()!='taxon'">
<h1><xsl:value-of select="name()"/></h1>
<xsl:for-each select="child::*">
<xsl:if test="not(child::*)">
<!--self-->
<b><xsl:value-of select="name()"/>: </b>
<xsl:value-of select="child::text()"/> <xsl:text> </xsl:text>
</xsl:if>
<xsl:for-each select="child::*">
<xsl:if test="not(child::*)">
<!--child-->
<b><xsl:value-of select="name()"/>: </b>
<xsl:value-of select="child::text()"/> <xsl:text> </xsl:text>
</xsl:if>
<xsl:for-each select="child::*">
<xsl:if test="not(child::*)">
<!--grandson-->
<b><xsl:value-of select="name()"/>: </b>
<xsl:value-of select="child::text()"/> <xsl:text> </xsl:text>
</xsl:if>
<xsl:for-each select="child::*">
<!--grandson's son-->
<b><xsl:value-of select="name()"/>: </b>
<xsl:value-of select="child::text()"/> <xsl:text> </xsl:text>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
The xslt has an extension of .xsl
We run the transform via a batch file.
The batch file commands are something like this:
for name in `ls xml/*.xml` do echo $name newname=`basename $name ".xml"` /usr/local/j2sdk1.4.0/bin/java org.apache.xalan.xslt.Process -in xml/$newname.xml -xsl unc.xsl -out html/$new name.html done