home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0" encoding="utf-8"?>
- <!-- ===========================================================
- Category: HTML
- Sub-category: TextBox
- Author: David Silverlight
- HeadGeek@xmlpitstop.com
- Created: 2001-05-16
- Description:-
- This series of textboxes is generated using the pull method
- of extracting xml elements. A template is defined for each
- element allowing us to customize the attributes, rather than
- using the values in the XML document. Also note that we are
- using the 'Push' method to transform data from our xml
- document. The Push method is an approach where templates are
- used extensively. Using the "Push" method, we are
- essentially defining templates for each of our xml elements
- and "Pushing" our xml data towards it.
- ================================================================ -->
- <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>Generating a text box from xml (Push method)</h1>
- <xsl:apply-templates />
- </body>
- </html>
- </xsl:template>
-
- <xsl:template match="employees">
- <xsl:apply-templates />
- </xsl:template>
-
- <xsl:template match="employee">
- <xsl:apply-templates />
- </xsl:template>
-
- <!-- Generate Input text box for "employeename" -->
- <xsl:template match="employeename">Employee Name:
- <xsl:element name="Input">
- <!-- Set the Size of the textbox -->
- <xsl:attribute name="size">30</xsl:attribute>
- <!-- Set the Size of the textbox -->
- <xsl:attribute name="maxlength">30</xsl:attribute>
- <!-- Set the value of the text box -->
- <xsl:attribute name="value">
- <xsl:value-of select="text()" />
- </xsl:attribute>
- <br />
- </xsl:element>
- </xsl:template>
-
- <!-- Generate Input text box for "hourlyrate" -->
- <xsl:template match="hourlyrate">
- Hourly Rate:
- <xsl:element name="Input">
- <!-- Set the Size of the textbox -->
- <xsl:attribute name="size">12</xsl:attribute>
- <!-- Set the Size of the textbox -->
- <xsl:attribute name="maxlength">12</xsl:attribute>
- <!-- Set the value of the text box -->
- <xsl:attribute name="value">
- <xsl:value-of select="text()" />
- </xsl:attribute>
- <br />
- </xsl:element>
- </xsl:template>
-
- <!-- Generate Input text box for "department" -->
- <xsl:template match="department">
- Department:
- <xsl:element name="Input">
- <!-- Set the Size of the textbox -->
- <xsl:attribute name="size">35</xsl:attribute>
- <!-- Set the Size of the textbox -->
- <xsl:attribute name="maxlength">35</xsl:attribute>
- <!-- Set the value of the text box -->
- <xsl:attribute name="value">
- <xsl:value-of select="text()" />
- </xsl:attribute>
- <br />
- </xsl:element>
- </xsl:template>
-
- <!-- Generate Input text box for "nativelanguage" -->
- <xsl:template match="nativelanguage">
- Spoken Language
- <xsl:element name="Input">
- <!-- Set the Size of the textbox -->
- <xsl:attribute name="size">15</xsl:attribute>
- <!-- Set the Size of the textbox -->
- <xsl:attribute name="maxlength">15</xsl:attribute>
- <!-- Set the value of the text box -->
- <xsl:attribute name="value">
- <xsl:value-of select="text()" />
- </xsl:attribute>
- <br />
- </xsl:element>
- </xsl:template>
-
- <!-- Generate Input text box for "primarylanguage" -->
- <xsl:template match="primarylanguage">
- Programming Language
- <xsl:element name="Input">
- <!-- Set the Size of the textbox -->
- <xsl:attribute name="size">20</xsl:attribute>
- <!-- Set the Size of the textbox -->
- <xsl:attribute name="maxlength">20</xsl:attribute>
- <!-- Set the value of the text box -->
- <xsl:attribute name="value">
- <xsl:value-of select="text()" />
- </xsl:attribute>
- <br />
- </xsl:element>
- </xsl:template>
- </xsl:stylesheet>