>> English << | Français | Deutsch | Magyar | 中文 | Polski ZVON > Tutorials > XSLT Tutorial
>> Page 5 << | Prev | Next | Contents | Element Index

An XSL processors parses an XML source and tries to find a matching template rule. If it does, instructions inside matching template are evaluated.

XSLT stylesheet 1

XML Source
<source>

<bold>Hello, world.</bold>
<red>I am </red>
<italic>fine.</italic>

</source>

Output
<p>
  <b>Hello, world.</b>
</p>

<p style="color:red">I am </p>

<p>
  <i>fine.</i>
</p>

HTML view

Hello, world.

I am

fine.

XSLT stylesheet
<xsl:stylesheet version = '1.0'
     xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

<xsl:template match="bold">
     <p>
          <b>
               <xsl:value-of select="."/>
          </b>
     </p>
</xsl:template>

<xsl:template match="red">
     <p style="color:red">
          <xsl:value-of select="."/>
     </p>
</xsl:template>

<xsl:template match="italic">
     <p>
          <i>
               <xsl:value-of select="."/>
          </i>
     </p>
</xsl:template>


</xsl:stylesheet>