home *** CD-ROM | disk | FTP | other *** search
- <?xml version="1.0" encoding="utf-8"?>
- <!-- ===========================================================
- Styelsheet: EmployeeStringFuncs.xsl
- Category: DataFormatting
- Sub-category: String Formatting Functions
- Author: David Silverlight
- HeadGeek@xmlpitstop.com
- Created: 2001-05-16
- Description:-
- This stylsheet demonstrates how various string functions
- (string-length, substring-before, substring-after, concat)
- can be used to extract specific portions of your string data.
- An example is also provided on how to perform upper and
- lower casing conversions.
- ================================================================ -->
- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:user="http://mycompany.com/mynamespace" version="1.0">
- <xsl:output method="html" encoding="ISO-8859-1" doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN"/>
- <xsl:template match="/">
- <html>
- <head>
- <title>DataFormatting - String Formatting Functions</title>
- <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>Employee Listing</h1>
- <table border="1">
- <tr>
- <th>Select</th>
- <th>Select</th>
- <th>Select</th>
- <th>string-length</th>
- <th>substring-before 'n'</th>
- <th>substring-after 'n'</th>
- <th>concat</th>
- <th>contains 'i'</th>
- <th>'uppercase'</th>
- <th>'lowercase'</th>
- </tr>
-
- <xsl:for-each select="/employees/employee">
- <tr>
- <td>
- <xsl:value-of select="@EmployeeID" />
- </td>
- <td>
- <xsl:value-of select="@FirstName" />
- </td>
- <td>
- <xsl:value-of select="@LastName" />
- </td>
- <td>
- <xsl:value-of select="string-length(@FirstName)" />
- </td>
- <td>
- <xsl:value-of select="substring-before(@FirstName, 'n')" />
- </td>
- <td>
- <xsl:value-of select="substring-after(@FirstName, 'n')" />
- </td>
- <td>
- <xsl:value-of select="concat(@FirstName, ' ', @LastName)" />
- </td>
- <td>
- <xsl:value-of select="contains(@FirstName, 'i')" />
- </td>
- <td>
- <xsl:value-of select="translate(@LastName,'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
- </td>
- <td>
- <xsl:value-of select="translate(@FirstName,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')"/>
- </td>
- </tr>
- </xsl:for-each>
- </table>
- </body>
- </html>
- </xsl:template>
- </xsl:stylesheet>