Although XML and XSL are very complex technologies, with the simple examples in this article you learn that you don't need extensive knowledge to do some powerful things. You can store your data in an XML document and use a basic XSL style sheet to select, filter, and sort the elements of an XML document for display as HTML in a Web browser.
Welcome to Bucaro TecHelp!

Bucaro TecHelp
HTTPS Encryption not required because no account numbers or
personal information is ever requested or accepted by this site

About Bucaro TecHelp About BTH User Agreement User Agreement Privacy Policy Privacy Site Map Site Map Contact Bucaro TecHelp Contact RSS News Feeds News Feeds

Extensible Stylesheet Language (XSL) Basics

XSL is an XML language that is used to "transform" an XML document into a different form. Generally, XSL is used to create a "template" that a Web browser uses to transform an XML document into an HTML webpage. In this article, you'll learn how easy it is to do powerful things with XSL.

First of all, you'll need some basic knowledge of XML, nothing advanced, but you should know how to create a "well-formed" XML document. You can learn basic XML from articles on this website and other sources. You need a basic knowledge of XML because XSL works on XML and XSL itself is XML.

An XSL document, referred to as an "XSL style sheet", allows you to select, filter, and sort the elements of an XML document for display as HTML in a Web browser. You can even include scripts in an XSL style sheet that let you modify or add information to the XML document. We'll stick with selecting, filtering, and sorting in this article.

Shown below is a very simple XML document. This document represents a book list that contains only one "book" element. The book element has child nodes that contain the "title, publisher, author, isbn, pubdate, and price of the book.

<?xml version="1.0"?>

  <title>XML in a Nutshell</title>

If you would like to follow along, create a new file in a simple ASCII text editor, like Windows Notepad, paste the above XML into the text file, and save it with the file name "booklist.xml".

Shown below is a very simple XSL document to display the data in the booklist XML document.

<?xml version="1.0"?>

<xsl:stylesheet xmlns:xsl="">
  <xsl:template match="/">
    <p>Book List</p>
    <tr><td>Title: </td><td>
    <xsl:value-of select="book/title" /></td></tr>
    <tr><td>Publisher: </td><td>
    <xsl:value-of select="book/publisher" /></td></tr>
    <tr><td>Author: </td><td>
    <xsl:value-of select="book/author" /></td></tr>
    <tr><td>ISBN: </td><td>
    <xsl:value-of select="book/isbn" /></td></tr>
    <tr><td>Pub Date: </td><td>
    <xsl:value-of select="book/pubdate" /></td></tr>
    <tr><td>Price: </td><td>
    <xsl:value-of select="book/price" /></td></tr>

If you would like to follow along, paste the above XSL into the text file and save it with the file name "example1.xsl".

RSS Feed RSS Feed

Follow Stephen Bucaro Follow @Stephen Bucaro

Fire HD
[Site User Agreement] [Privacy Policy] [Site map] [Search This Site] [Contact Form]
Copyright©2001-2024 Bucaro TecHelp 13771 N Fountain Hills Blvd Suite 114-248 Fountain Hills, AZ 85268