XSLT in depth

What is an xslt? Well briefly we use to display our xml files as like HTML which in the case we code our xslt files the same way we do static HTML pages. To keep in mind that even XSLT is xml! to begin with a XSLT file we need to identify a few of things:

  1. As usual the first line is <?xml version=1.0″?> to indicate that this is an xml document,
  2. second line goes <xsl:stylesheet xmlns:xsl=”http://www.w3.org/1999/XSL/Transform” version=”1.0″> to specify the namespace
  3. Finally we end the document with </xsl:stylesheet>

So far we have successfully created our xslt file! keep in mind that when we save the file, we save it with the xsl extension not the xslt extension.

After all our xslt document looks for a root note which is the first tag in our xml file. The root template creation steps:

  1. start writing the root document <xsl:template match”/”> the forward slash identifies the match of the first root element of the xml file
  2. we close the element </xsl-template>

Sample xslt document:

<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://
<xsl:output method="html"/>
<xsl:template match="/">
<html><head><title>Wonders of the
<p align="center"><img
src="herodotus.jpg" width="120"
height="171" /></p>
<p>The famous Greek historian
Herodotus wrote of seven great
architectural achievements. And
although his writings did not
survive, he planted seeds for
what has become the list of the
<strong>Seven Wonders of the
Ancient World</strong>.


Leave a Reply

Your email address will not be published. Required fields are marked *