I hacked this up in the middle of the night to produce a nicely formatted list of software, but you can of course just use this as a basis for producing other lists.

XML input

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="ossd.xsl"?>

<softwarelist>
 <pack>
   <package>7zip</package>
   <desc>7-Zip is a file archiver with high compression ratio</desc>
   <url>http://www.7-zip.org/</url>
   <license>LGPL</license>
   <save>2250</save>
   <alt>Winzip</alt>
  </pack>

  <pack>
   <package>Apache</package>
   <desc>The Apache HTTP Server Project is an effort to develop and maintain an open-source HTT
P server for modern operating systems including UNIX and Windows NT</desc>
   <url>http://httpd.apache.org/</url>
   <license>Apache</license>
   <save>40000</save>
   <alt>IIS, Netscape</alt>
  </pack>
</softwarelist>

XSL Stylesheet

<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  <xsl:output method="html" indent="yes"/>
  <xsl:decimal-format name="euro" decimal-separator="," grouping-separator="."/>
  <xsl:template match="*">
    <xsl:apply-templates/>
  </xsl:template>

  <xsl:template match="pack">
    <tr>
      <td> <xsl:apply-templates select="package"/> </td>
      <td> <xsl:apply-templates select="desc"/> </td>
      <td> <xsl:apply-templates select="license"/> </td>
      <td> <xsl:apply-templates select="save"/> </td>
      <td> <xsl:apply-templates select="alt"/> </td>
      <td> <xsl:apply-templates select="url"/> </td>
    </tr>
  </xsl:template>

  <xsl:template match="package">
    <xsl:value-of select="."/>
  </xsl:template>

  <xsl:template match="desc">
    <xsl:value-of select="."/>
  </xsl:template>

  <xsl:template match="url">
    <xsl:element name="a"><xsl:attribute name="href"><xsl:value-of select="."/></xsl:attribute><xsl:
attribute name="title"><xsl:value-of select="."/></xsl:attribute>
go</xsl:element>
  </xsl:template>

  <xsl:template match="alt">
    <xsl:value-of select="."/>
  </xsl:template>

  <xsl:template match="save">
    <xsl:variable name="money" select="."/>
    <xsl:value-of select="format-number($money, '#.###,00', 'euro')"/>
  </xsl:template>

  <xsl:template match="softwarelist">
    <HTML>
      <HEAD></HEAD>
      <BODY>
        <table width="100%">
          <xsl:apply-templates/>
        </table>
      </BODY>
    </HTML>
  </xsl:template>
</xsl:stylesheet>

Then use can open the XML file in a modern browser and Bob's your uncle. If you prefer, use xsltproc input.xml to produce the HTML.

HTML output

The HTML produced by the stylesheet (I'll leave it to you to add CSS to it) is like this:

<HTML>
<HEAD><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"></HEAD>
<BODY><table width="100%">
   <tr>
<td>7zip</td>
<td>7-Zip is a file archiver with high compression ratio</td>
<td>LGPL</td>
<td>2.250,00</td>
<td>Winzip</td>
<td><a href="http://www.7-zip.org/" title="http://www.7-zip.org/">
                go</a></td>
</tr>

   <tr>
<td>Apache</td>
<td>The Apache HTTP Server Project is an effort to develop and maintain an open-source HTTP server f
or modern operating systems including UNIX and Windows NT</td>
<td>Apache</td>
<td>40.000,00</td>
<td>IIS, Netscape</td>
<td><a href="http://httpd.apache.org/" title="http://httpd.apache.org/">
                go</a></td>
</tr>
</table></BODY>
</HTML>

Comments

blog comments powered by Disqus