XSL Examples

Several examples below use an xml file containing a list of CDs. Each CD entry contains the fields: title, artist, country, company, price, and year. Click here to see this file. To view all examples you must use Internet Explorer 6.x or later.
Example 1: Select Title/Artist fields with Yellow Background Stylesheet (Uses xsl:for-each and xsl:value-of constructs)
Example 2: Selects Title/Artist for the first Entry Stylesheet (drops the xsl:for-each so only the first item is selected)
Example 3: Selects Title/Artist for A ll Entries Stylesheet, for-each Same as example 1 except for yellow background)
Example 4: transform.html uses JavaScript IE-only) to create an xml object (Same as Ex. 3) Stylesheet xml object has load, transformNode and write operations
Example 4: transform2.html uses JavaScript (IE and Mozilla) to create an xml object (Same as Ex. 3) Stylesheet xml object has load, importStylesheet, transformToDocument, XMLSerializer and write operations
Compare transform.html source with transform2.html sourceView in Firefox ONLY
Example 5: CD Catalog Stylesheet (Uses xsl:sort to sort output on artist)
Example 6: CD Catalog Stylesheet Using Filter (Uses select="catalog/cd[artist='Bob Dylan']">)
Example 7: CD Catalog Stylesheet Using Conditional IF (Remember to View Source)
Example 8: CD Catalog Stylesheet Using Conditional Choose (Remember to View Source)
Example 9: Enrollments(works only in I.E.) Stylesheet (Remember to View Source)
Here is a new xml file of U.S. Presidents with examples below
Example 10:Color CodedStylesheet Using Choose
Example 11:Alternate rows in boldStylesheet Using select/if
Example 12:Output to a TableStylesheet Using list/table mode
Example 13:Multiple Sorting MethodsStylesheet Using Sorting