XSL Translation from XML to HTML

“Vocabulary.xsl”

 

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”>

     <html>

     <head>

     <title>Vocabulary Words</title>

     <style type=”text/css”>

         body        {font: 10pt verdana;}

         table       {font: 10pt verdana;}

     </style>

     </head>

     <body>

     <h2>Vocabulary Words</h2>

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

        <xsl:sort select=”Word”/>

      </xsl:apply-templates>

     </body>

     </html>

   </xsl:template>

 

   <xsl:template match=”Set”>

      <p>

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

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

      </p>

   </xsl:template>

</xsl:stylesheet>

 

 

Leave a Reply

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