home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F19538_LinksPull2.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2001-10-04  |  2.4 KB  |  64 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!-- ===========================================================
  3.   Category:       HTML
  4.   Sub-category:   Hyperlinks
  5.   Author:         David Silverlight
  6.                   HeadGeek@xmlpitstop.com
  7.   Created:        2001-05-16
  8.   Description:-
  9.     This stylsheet demonstrates how to create hyperlinks from an
  10.     xml document. Also note that we are using the Pull method to
  11.     extract data from our xml document.  The pull method is an
  12.     approach where the use of templates is minimized and data is
  13.     accessed by 'pulling' it from our xml document.  One other
  14.     point to mention is that we are using the shorthand for
  15.     writing attributes in our hyperlinks which helps to
  16.     streamline the code readability just slightly.
  17. ================================================================ -->
  18. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  19.   <xsl:output method="html" />
  20.  
  21.   <xsl:template match="/">
  22.     <html>
  23.       <head>
  24.         <style type="text/css">
  25.         H1 {COLOR: red; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
  26.         H2 {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  27.         .head {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
  28.         .subhead {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  29.         .text {COLOR: black; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  30.         TH {COLOR: white; FONT-FAMILY: Arial; background-color: darkblue;}
  31.         TD {COLOR: darkblue; FONT-FAMILY: Arial}
  32.         TR { background-color: beige; }
  33.         BODY { background-color: beige; }
  34.         </style>
  35.       </head>
  36.       <body>
  37.         <h1>Creating Hyperlinks from xml (Using the Pull method)</h1>
  38.         <table border="1">
  39.           <tr>
  40.             <th>name</th>
  41.             <th>description</th>
  42.             <th>url</th>
  43.           </tr>
  44.           <xsl:for-each select="links/link">
  45.             <tr>
  46.               <td>
  47.                 <xsl:value-of select="@name" />
  48.               </td>
  49.               <td>
  50.                 <xsl:value-of select="@description" />
  51.               </td>
  52.               <td>
  53.                 <a>
  54.                   <xsl:attribute name="href">{@url}</xsl:attribute>
  55.                   <xsl:value-of select="@url" />
  56.                 </a>
  57.               </td>
  58.             </tr>
  59.           </xsl:for-each>
  60.         </table>
  61.       </body>
  62.     </html>
  63.   </xsl:template>
  64. </xsl:stylesheet>