XML information pipe

Ihre Spezialisten für XML

Banner Werbung

XSLT introduction

With XSL you can freely modify any source text. XSLT stylesheet 1 and XSLT stylesheet 2 produce different output from the same source file.

Examples:


XSLT introduction

Example 1:

XSLT Stylesheet 1:
XML source: <source>
   <title>XSL</title>
   <author>John Smith</author>
</source>
XSLT stylesheet: <xsl:stylesheet version = '1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

   <xsl:template match="/">
      <h1>
         <xsl:value-of select="//title"/>
      </h1>
      <h2>
         <xsl:value-of select="//author"/>
      </h2>
   </xsl:template>

</xsl:stylesheet>
HTML view:

XSL

John Smith

Output: <h1>XSL</h1>
<h2>John Smith</h2>


Example 2:

XSLT Stylesheet 2:
XML source: <source>
   <title>XSL</title>
   <author>John Smith</author>
</source>
XSLT stylesheet: <xsl:stylesheet version = '1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

   <xsl:template match="/">
      <h2>
         <xsl:value-of select="//author"/>
      </h2>
      <h1>
         <xsl:value-of select="//title"/>
      </h1>
   </xsl:template>

</xsl:stylesheet>
HTML view:

John Smith

XSL

Output: <h2>John Smith</h2>
<h1>XSL</h1>