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 / F19274_EmpElemTextBoxPush1.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2001-10-04  |  2.6 KB  |  71 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!-- ===========================================================
  3.   Category:       HTML
  4.   Sub-category:   TextBox
  5.   Author:         David Silverlight
  6.                   HeadGeek@xmlpitstop.com
  7.   Created:        2001-05-16
  8.   Description:-
  9.     This series of textboxes is generated using the pull method
  10.     of extracting xml elements. Each element will generate a
  11.     text box. Also note that we are using the "Push" method to
  12.     transform data from our xml document. The Push method is an
  13.     approach where templates are used extensively.  Using the
  14.     "Push" method, we are essentially defining templates for
  15.     each of our xml elements and "Pushing" our xml data towards
  16.     it.
  17. ================================================================ -->
  18. <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  19.   <xsl:output method="html" />
  20.   <xsl:template match="/">
  21.     <html>
  22.       <head>
  23.         <style type="text/css">
  24.         H1 {COLOR: red; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
  25.         H2 {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  26.         .head {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 14pt;}
  27.         .subhead {COLOR: darkblue; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  28.         .text {COLOR: black; FONT-FAMILY: Arial; FONT-SIZE: 12pt;}
  29.         TH {COLOR: white; FONT-FAMILY: Arial; background-color: darkblue;}
  30.         TD {COLOR: darkblue; FONT-FAMILY: Arial}
  31.         TR { background-color: beige; }
  32.         BODY { background-color: beige; }
  33.         </style>
  34.       </head>
  35.       <body>
  36.         <h1>Generating a text box from xml (Push Method)</h1>
  37.         <xsl:apply-templates />
  38.       </body>
  39.     </html>
  40.   </xsl:template>
  41.  
  42.   <xsl:template match="employees">
  43.     <xsl:apply-templates />
  44.   </xsl:template>
  45.  
  46.   <xsl:template match="employee">
  47.     <!-- The following for-each loop will iterate through all of the child elements of employee -->
  48.     <xsl:for-each select="*">
  49.       <xsl:value-of select="name(.)" />
  50.  
  51.       <xsl:element name="Input">
  52.         <!-- Set the Size of the textbox -->
  53.         <xsl:attribute name="size">
  54.           <xsl:value-of select="string-length(.)" />
  55.         </xsl:attribute>
  56.  
  57.         <!-- Set the Size of the textbox -->
  58.         <xsl:attribute name="maxlength">
  59.           <xsl:value-of select="string-length(.) + 5" />
  60.         </xsl:attribute>
  61.  
  62.         <!-- Set the value of the text box -->
  63.         <xsl:attribute name="value">
  64.           <xsl:value-of select="text()" />
  65.         </xsl:attribute>
  66.  
  67.         <br />
  68.       </xsl:element>
  69.     </xsl:for-each>
  70.   </xsl:template>
  71. </xsl:stylesheet>