XSLT Transformation and HTML View

This section provides a tutorial example on how to perform XSLT (Extensible Stylesheet Language Transformations) in XML Notepad 2007.

XML Notepad 2007 can not be used to apply generic XSLT (Extensible Stylesheet Language Transformations). But it can apply special XSLT transformation that generates HTML documents.

The example below shows you how XML Notepad 2007 can be used apply an XSLT transformation as HTML viewer for RSS documents.

1. Assuming we have the following RSS document, rss.xml, with rss-viewer.xsl specified in the document:

?<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="rss-viewer.xsl"?>
<rss version="2.0">
    <title>Science - Google News</title>
    <copyright>&amp;copy;2013 Google</copyright>
    <pubDate>Sun, 1 Mar 2013 22:22:30 GMT</pubDate>
    <lastBuildDate>Sun, 1 Mar 2013 22:22:30 GMT</lastBuildDate>
      <title>Science - Google News</title>
      <title>Privately Financed Spaceship Roars Closer to Space 
         - New York Times</title>
      <guid isPermaLink="false">tag:...:cluster=52778136490111</guid>
      <pubDate>Sun, 1 Mar 2013 21:27:11 GMT</pubDate>
      <description>For the more than 500 space...</description>
      <title>NASA eyes monster hurricane on Saturn - Fox News</title>
      <guid isPermaLink="false">tag:...:cluster=52778138308485</guid>
      <pubDate>Sun, 1 Mar 2013 11:40:58 GMT</pubDate>
      <description>Spectacular new images from a NASA...</description>
      <title>Fossil Discovery Traces Dinosaur Family Line to Africa 
         - Headlines &amp; Global News</title>
      <guid isPermaLink="false">tag:...:cluster=52778138328576</guid>
      <pubDate>Sun, 1 Mar 2013 13:21:53 GMT</pubDate>
      <description>The discovery of fossils dating...</description>
    <description>Google News</description>

2. Assuming we also have the following RSS to HTML XSLT transformation template, rss-viewer.xsl:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
<!-- rss-viewer.xsl
 - Copyright (c) 2013, HerongYang.com, All Rights Reserved.

<xsl:template match='/rss'>
<b><xsl:value-of select='channel/title'/></b> - 
<xsl:value-of select='channel/description'/> -
<i><xsl:value-of select='channel/pubDate'/></i>
<ul><xsl:apply-templates select='channel/item'/></ul>

<xsl:template match='item'>
<b><xsl:value-of select='title'/></b> - 
<xsl:value-of select='description'/> -
<i><xsl:value-of select='pubDate'/></i>


3. Open rss.xml in XML Notepad 2007 and click the "XSL Output" tab. The XSLT template, rss-viewer.xsl, will be applied automatically. You see the transformed HTML document be rendered and displayed:
XML Notepad 2007 - HTML View

4. Right-mouse click on HTML display area, and select "View source". You see HTML source code showing up in Notepad editor:

  <body><b>Science - Google News</b> - 
Google News -
<i>Sun, 1 Mar 2013 22:22:30 GMT</i><ul>
      <li><b>Privately Financed Spaceship Roars Closer to...</b> - 
For the more than 500 space tourists who have signed up for a trip...
<i>Sun, 1 Mar 2013 21:27:11 GMT</i></li>
      <li><b>NASA eyes monster hurricane on Saturn - Fox News</b> - 
Spectacular new images from a NASA spacecraft orbiting Saturn have...
<i>Sun, 1 Mar 2013 11:40:58 GMT</i></li>
      <li><b>Fossil Discovery Traces Dinosaur Family Line to...</b> - 
The discovery of fossils dating back to about 10 million years...
<i>Sun, 1 Mar 2013 13:21:53 GMT</i></li>

Of course, if the XSLT file is not provided in the XML document, you can specify it through the "XSLT location" field.

Last update: 2013.

Table of Contents

 About This Book

 Introduction of XML (eXtensible Markup Language)

 XML File Syntax

 XML File Browsers

 DOM (Document Object Model) Programming Interface

 SAX (Simple API for XML) Programming Interface

 DTD (Document Type Definition) Introduction

 Syntaxes of DTD Statements

 Validating an XML Document against the Specified DTD Document Type

 XSD (XML Schema Definition) Introduction

 Syntaxes of XSD Statements

 Validating XML Documents Against Specified XML Schemas

 XSL (Extensible Stylesheet Language) Introduction

 XSLT (XSL Transformations) Introduction

 Java Implementation of XSLT

 XPath (XML Path) Language

 XSLT Elements as Programming Statements

 Control and Generate XML Element in the Result

XML Notepad - XML Editor

 What Is XML Notepad?

 Downloading and Installing XML Notepad

 Creating XML Documents in Tree View

 Viewing XML Documents in Source Code

 Converting XML in Pretty Print Format

 XSD Validation and Error List

XSLT Transformation and HTML View

 XML Tools Plugin for Notepad++

 XML 1.1 Changes and Parsing Examples

 Outdated Tutorials


 PDF Printing Version