what?   why?   how?   some examples   ...and some links   ||   group ASP project   grade report

        The best place to begin is with the first line of every XML file, the XML prolog. It looks something like this:

<?xml version="1.0"?>

This defines the document as an XML file. Note that this leaves the <xml>tag reserved; you can't define it as any kind of data type later, as it is required for xml-related system functions.

        Next come the tags. We'll bring back the example from the "what" page:

<animal>
   <mammal>
       <class>bovinus</class>
       <species>cow</species>
       <speech>Moo!</speech>
   </mammal>
<animal>

        Tags can also contain attributes. An example of this in HTML is the image tag, with the source attribute -- <img src="filename.jpg">. The previous example rewritten with an attribute tag might start as:

<creature kingdom="animal" phylum="mammal">
    <class>bovinus</class>

...and so on.

        With the basics of the XML document understood, we'll next analyze the XSL document.

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">

These two lines define the document (a) as an XML file, and then (b) as an XSL stylesheet. The "xmlns" link goes to the current XSL standard, so that the processor knows what it's dealing with.

<xsl:template match="/">

This is the template to match the / point; in other words, the root of the document. Basically, this informs the browser that it's the start point for processing the XML. Note that the next line, as well as a few others, are in plain text -- i.e. not an XSL tag. These are just put out into the web browser, so that you can put headings, punctuation, etc. into your document.

<xsl:apply-templates select="//class" />

This searches for anything in a <class> tag in the XML file, and then processes it through the xsl class template. (More on that later.)

<br />

As mentioned in the "why" section, this is simply a normal break tag; however, since break tags don't have closers, the / informs the browser that there will be no close tag. (Note that the xsl:apply-templates tag has one, as well.) The next few lines are more apply-template tags. After that follows:

</xsl:template>

This closes the xsl:template tag, finishing off the base template..

<xsl:template match="//class">

This starts another XSL template; however, rather than being the base one, this is the one called to handle anything under a <class> tag.

<xsl:value-of />

The xsl:value-of command tells the processor to simply output the value in the XML tag. The template then ends, and a couple more templates that do the same, ending with:

</xsl:stylesheet>

which ends the stylesheet.

        Again, to see the output, click here.

        Of course, this is an incredibly simple example. For a much more in-depth one created by Dave for the group presentation, check out the examples page.

        XML also has a lot more to it, so that larger scale projects can be handled easier. Two of these are APIs -- SAX (Simple API for XML) and DOM (Document Object Model). For more on these, see under the page for Group 2 and Group 3, respectively, as these are their projects.