home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0" encoding="utf-8"?>
- <!-- ===========================================================
- Category: HTML
- Sub-category: Hyperlinks
- Author: David Silverlight
- HeadGeek@xmlpitstop.com
- Created: 2001-05-16
- Description:-
- This stylsheet demonstrates how to create hyperlinks from an
- xml document. Also note that we are using the Pull method to
- extract data from our xml document. The pull method is an
- approach where the use of templates is minimized and data is
- accessed by 'pulling' it from our xml document. One other
- point to mention is that we are using the shorthand for
- writing attributes in our hyperlinks which helps to
- streamline the code readability just slightly.
- ================================================================ -->
- <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
- <xsl:output method="html" />
-
- <xsl:template match="/">
- <html>
- <head>
- <style type="text/css">
- H1 {COLOR: red; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
- H2 {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
- .head {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
- .subhead {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
- .text {COLOR: black; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
- TH {COLOR: white; FONT-FAMILY: Arial; background-color: darkblue;}
- TD {COLOR: darkblue; FONT-FAMILY: Arial}
- TR { background-color: beige; }
- BODY { background-color: beige; }
- </style>
- </head>
- <body>
- <h1>Creating Hyperlinks from xml (Using the Pull method)</h1>
- <table border="1">
- <tr>
- <th>name</th>
- <th>description</th>
- <th>url</th>
- </tr>
- <xsl:for-each select="links/link">
- <tr>
- <td>
- <xsl:value-of select="@name" />
- </td>
- <td>
- <xsl:value-of select="@description" />
- </td>
- <td>
- <a>
- <xsl:attribute name="href">{@url}</xsl:attribute>
- <xsl:value-of select="@url" />
- </a>
- </td>
- </tr>
- </xsl:for-each>
- </table>
- </body>
- </html>
- </xsl:template>
- </xsl:stylesheet>