XSLT Transformation

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

XML Tools Plugin can also be used to perform XSLT (Extensible Stylesheet Language Transformations).

1. Assuming we have the following XML document, dictionary.xml:

<?xml version="1.0"?>
<dictionary>
<!-- dictionary.xml
 - Copyright (c) 2013, HerongYang.com, All Rights Reserved.
-->
 <word acronym="true">
  <name>XML</name>
  <definition reference="Herong&apos;s Notes">eXtensible Markup 
Language.</definition>
  <update date="2002-12-23"/>
 </word>
 <word symbol="true">
  <name>&lt;</name>
  <definition>Mathematical symbol representing the "less than" logical 
operation, like: 1&lt;2.</definition>
  <definition>Reserved symbol in XML representing the beginning of 
tags, like: <![CDATA[<p>Hello world!</p>]]>
  </definition>
 </word>
 <word symbol="false" acronym="false">
  <name>extensible</name>
  <definition>Capable of being extended.</definition>
 </word>
</dictionary>

2. Assuming we also have the following XSLT transformation template, dictionary.xsl:

<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- dictionary.xsl, version 5.0
 - Copyright (c) 2013, HerongYang.com, All Rights Reserved.
-->

<xsl:template match="dictionary">
  <pre>
  dictionary
  <xsl:apply-templates/>
  </pre>
 </xsl:template>
 <xsl:template match="word">
   word
    |-acronym=<xsl:value-of select="@acronym"/>
    |-symbol=<xsl:value-of select="@symbol"/>
  <xsl:apply-templates/>
 </xsl:template>
 <xsl:template match="name">
    name
     <xsl:value-of select="."/>
 </xsl:template>
 <xsl:template match="definition">
    definition
     <xsl:value-of select="."/>
 </xsl:template>
 <xsl:template match="update">
    date
     |-acronym=<xsl:value-of select="@date"/>
 </xsl:template>

</xsl:stylesheet>

3. Open dictionary.xml in Notepad++ and click menu "Plugins" > "XML Tools" > "XSL Transformation Settings". You see a dialog box showing up.

4. Enter "dictionary.xsl" and click the "Transform" button. You see the transformation output showing up:

<?xml version="1.0"?>
<pre>
  dictionary
  

   word
    |-acronym=true
    |-symbol=
  
    name
     XML
  
    definition
     eXtensible Markup 
Language.
  
    date
     |-acronym=2002-12-23
 
 
   word
    |-acronym=
    |-symbol=true
  
    name
     &lt;
  
    definition
     Mathematical symbol representing the "less than" logical 
operation, like: 1&lt;2.
  
    definition
     Reserved symbol in XML representing the beginning of 
tags, like: &lt;p&gt;Hello world!&lt;/p&gt;

... 
</pre>

Last update: 2016.

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

XML Tools Plugin for Notepad++

 What Is XML Tools Plugin for Notepad++

 Downloading and Installing Notepad++ with XML Tools

 Converting XML in Pretty Print Format

 XSD Validation and Error List

XSLT Transformation

 Other XML Tools Functions

 XML 1.1 Changes and Parsing Examples

 Outdated Tutorials

 References

 PDF Printing Version