XML Tutorials - Herong's Tutorial Examples - v5.25, by Herong Yang
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) 2002-2018 HerongYang.com. All Rights Reserved. --> <word acronym="true"> <name>XML</name> <definition reference="Herong's Notes">eXtensible Markup Language.</definition> <update date="2002-12-23"/> </word> <word symbol="true"> <name><</name> <definition>Mathematical symbol representing the "less than" logical operation, like: 1<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) 2002-2018 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 < definition Mathematical symbol representing the "less than" logical operation, like: 1<2. definition Reserved symbol in XML representing the beginning of tags, like: <p>Hello world!</p> ... </pre>
Table of Contents
Introduction of XML (eXtensible Markup Language)
DOM (Document Object Model) Programming Interface
SAX (Simple API for XML) Programming Interface
DTD (Document Type Definition) Introduction
Validating an XML Document against the Specified DTD Document Type
XSD (XML Schema Definition) Introduction
Validating XML Documents Against Specified XML Schemas
XSL (Extensible Stylesheet Language) Introduction
XSLT (XSL Transformations) Introduction
XSLT Elements as Programming Statements
Control and Generate XML Element in the Result
PHP Extensions for XML Manipulation
Processing XML with Python Scripts
►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
XML Plugin Packages for Atom Editor