XSL Translation from XML to HTML



This is used in conjunction with “Vocabulary.xml” to demonstrate the power of XSL translation.  Put both in the same directory, load the .xml file in IE, and IE will automatically apply the transformation into HTML.


Key points: Translation from XML to HTML, Sorting on the Word elements, and Matching within the Ancor tag



<?xml version=”1.0″?>


<!— Created by Noah Coad, coad.net/noah, noah@coad.net, 3/23/04 —>


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

   <xsl:template match=”/Vocabulary”>



     <title>Vocabulary Words</title>

     <style type=”text/css”>

         body        {font: 10pt verdana;}

         table       {font: 10pt verdana;}




     <h2>Vocabulary Words</h2>

      <xsl:apply-templates select=”Set”>

        <xsl:sort select=”Word”/>






   <xsl:template match=”Set”>


         <a href=’http://dictionary.reference.com/search?q={Word}’><xsl:value-of select=”Word”/></a><br/>

         <xsl:value-of select=”Desc”/>






Leave a Reply

Your email address will not be published. Required fields are marked *