use of XSL:Template

Discussion in 'XML & RSS' started by mcdeere02, Aug 5, 2009.

Thread Status:
Not open for further replies.
  1. #1
    Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template match="/">
    <html>
    <body>
    <h2>My CD Collection</h2>
    <table border="1">
    <tr bgcolor="#9acd32">
    <th>Title</th>
    <th>Artist</th>
    </tr>
    <tr>
    <td>.</td>
    <td>.</td>
    </tr>
    </table>
    </body>
    </html>
    </xsl:template>

    </xsl:stylesheet>Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <catalog>
    <cd>
    <title>Empire Burlesque</title>
    <artist>Bob Dylan</artist>
    <country>USA</country>
    <company>Columbia</company>
    <price>10.90</price>
    <year>1985</year>
    </cd>
    .
    .
    </catalog>I am confused with the use of xsl:template. xsl:template in this example produces one table. Can we have moe than one tempate in an xsl document ? Is xsl:template used for producing table only or can it be used for something ese also ? what is meant by applying template to the element ? what happens when template is applied to an element ?

    Jayden
     
    mcdeere02, Aug 5, 2009 IP
  2. HivelocityDD

    HivelocityDD Peon

    Messages:
    179
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can clearly see that

    <xsl:template match="/"> matches all the content inside the xml body and it matches the conditions you define. Once you apply it the corresponding transformation is done on the xml content.

    Understand that xsl is different from CSS
     
    HivelocityDD, Aug 9, 2009 IP
Thread Status:
Not open for further replies.