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!

Welcome to Bucaro TecHelp!
Maintain Your Computer and Use it More Effectively
to Design a Web Site and Make Money on the Web

[About BTH]  [User Agreement]  [Privacy Policy]  [Site Map]  [Contact Form]  [Advertise on BTH]  [News Feed]

Google
Web
This Site
   WARNING!
What you learn from these Totally FREE
Einstein Newsletters could cause your friends to mistake you for someone else!
  [] automobiles
  [] business
  [] parenting
  [] computers
  [] contests
  [] education
  [] entertainment
  [] food/wine
  [] free stuff
  [] genealogy
  [] health/fitness
  [] home/garden
  [] humor
  [] marketing
  [] investing
  [] pets
  [] inspiration
  [] self-improve
  [] recreation
  [] travel
  [] womens stuff
  [] writing/reading
Click here and choose as many as you like!

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"?>

<book>
  <title>XML in a Nutshell</title>
  <publisher>O'Reilly</publisher>
    <author>
      <firstname>Scott</firstname>
      <lastname>Means</lastname>
    </author>
  <isbn>0596007647</isbn>
  <pubdate>2004</pubdate>
  <price>26.37</price>
</book>

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="http://www.w3.org/TR/WD-xsl">
  <xsl:template match="/">
    <p>Book List</p>
    <table>
    <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>
    </table>
  </xsl:template>
</xsl:stylesheet>

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

Programming Sections
XML

[Site User Agreement]  [Advertise on This site]  [Search This Site]  [Contact Form]
Copyright©2001-2007 Bucaro TecHelp P.O.Box 18952 Fountain Hills, AZ 85269