XSLT for Beginners

(1 vote, average 4.00 out of 5)

XSLT is short for 'X'tensible Stylesheet Language Transformation.  It is typically used in conjuction with an XML document to output HTML.  I would strongly advise that you become familiar with XML, if not already, before reading on since it will make this article more clear.

XSLT is a programming language that uses XPath expressions to locate information within an XML document.  All code is generally located in a .xsl file. From now on, I am going to refer to this ".xsl" file as a stylesheet.  There are several components that are needed to develop a stylesheet

  • Declaration Statement: This is required to consider the document a stylesheet. The W3C XSLT Recommendation is to use one of the following as the root element.
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  • Root node match: this is the entry point to the stylesheet: where the processing begins
<xsl:template match="/">
  • Additional templates to specify the formatting of elements and path through xml

Example

XML: 

xml
  

Stylesheet (XSL):


xsl

Output:


Model: Pontiac G6
Year: 2007

Model: Ford Mustang
Year: 2005
Partner Links:
Last Updated on Sunday, 18 July 2010 21:06  
Related Articles

» Access Windows Files From within a Ubuntu (Wubi) Install

So maybe you have just installed Ubuntu through the Wubi installation or have been using Ubuntu through Wubi for a while, but you find yourself trying to get access to your Window's documents/music/videos/etcetera from Ubuntu and your not sure where to look.  Well, the solution is pretty simple but not very intuitive for most users. Follow these instructions to get access to the files contained within your Windows installation:Assuming your using Ubuntu 10.xx, go to the top left:...

» How to Get the Latest Version of a Program in Ubuntu

Ubuntu, the popular Linux distribution, is well-known for its stability. This stability is due in part to its 6-month release cycle. Main programs included with Ubuntu are only updated every 6 months. This ensures that the developers have adequate time to test the software for regressions, bugs, and instabilities. However, sometimes it is nice to install the latest version of a program. This tutorial will use the application launcher Kupfer (like Gnome Do or Launchy) but the same procedure...

» Useful Opensource Java Libraries and Frameworks

Many open source libraries/frameworks exist for Java that can make coding certain tasks significantly easier, but finding these libraries/frameworks can be a different matter entirely! This article is devoted to compiling some of the more common useful Java libraries and some of the lesser known libraries.Apache Commons: ..................    Huge collection of useful components to help manage 'common' coding tasks. Commons.Lang and Commons.IO are extremely. Google...