XML information pipe

Ihre Spezialisten für XML

Banner Werbung

Page 3   |  Intructions inside xsl:template

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

Example


Intructions inside xsl:template

Example 1

XSLT Stylesheet 1:
XML source: <source>
   <bold>Hello, world</bold>
   <red>I am</red>
   <italic>fine.</italic>
</source>
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>
HTML view:

Hello, world

I am

fine.

HTML code:  p>
   <b>Hello, world</b>
</p>

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

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