Demonstrations of using each of the elements of XSL. (Note: Currently only a portion of the XSL Elements are coverred, but as the site grows, the list will become complete.)
| Stylesheet |
Description |
Files |
| xsl:attribute CreateEmployeeAttributes |
Converting attributes to Elements. This stylesheet processes a set of XML elements and uses the xsl:attribute element to generate a new xml file containing atrributes from the original xml document as well as new attributes created with XSL functions like a substring-before, substring-after and others. |
Output XSL File XML File Download this sample
|
| |
|
|
| xsl:calltemplate CallTemplatesByName |
Calling Templates by name. This stylesheet demonstrates the use of xsl:call-template() by calling multiple templates by name to display different HTML views of XSL output. |
Output XSL File XML File Download this sample
|
| |
|
|
| xsl:choose ComputerLanguages |
Translating computer language acronyms. This stylesheet demonstrates the use of xsl:choose by converting the computer language acronym stored in the "computerlanguage" element to the correct term displayed in an HTML table. |
Output XSL File XML File Download this sample
|
| |
|
|
| xsl:choose SpokenLanguages |
Translating spoken language acronyms. This stylesheet demonstrates the use of xsl:choose by converting the spoken language acronym stored in the "nativelanguage" element to the correct term displayed in an HTML table. For cases where the language translation is unknown, the actual acronym is used. |
Output XSL File XML File Download this sample
|
| |
|
|
| xsl:choose SpokenLanguagesToXML |
Translating spoken language acronyms in XML Output. This stylesheet demonstrates the use of xsl:choose by converting the spoken language acronym stored in the "nativelanguage" element to the correct term displayed in an xml file. For cases where the language translation is unknown, the actual acronym is used. |
Output XSL File XML File Download this sample
|
| |
|
|
| xsl:comment ListEmployeesWithComment |
Inserting comments in HTML output. This stylesheet demonstrates the use of xsl:comment to convert a set of elements to an HTML table. As part of the html output, comments will be placed within the HTML. To see the comment, view the source of this HTML. |
Output XSL File XML File Download this sample
|
| |
|
|
| xsl:copyof CopyOfEmployees |
Copying Elements. This stylesheet processes a set of XML elements and displays the result in XML. The copy-of element will copy the results of each employee element into the result tree. In this example, we are taking the original xml elements and creating a new xml document sorted by name. |
Output XSL File XML File Download this sample
|
| |
|
|
| xsl:copyof CopyOfInternetEmployees |
Copying Elements with a filter. This stylesheet processes a set of XML elements and displays the result in XML. An XPath statement can be applied to the select to copy selected elements to the result tree. In this example, we are outputting only the elements that contain employee elements whose department element = "Internet" |
Output XSL File XML File Download this sample
|
| |
|
|
| xsl:element CreateEmployeeElements |
Copying Elements. This stylesheet processes a set of XML elements as input and creates a new set of xml elements as output. In this example we are using the several XSL functions along with xsl:element to create two new xml elements(firstname and lastname) from our input as well as creating a third element directly from the xml input (department). |
Output XSL File XML File Download this sample
|
| |
|
|
| xsl:for-each ListEmployees |
Using for-each to display xml as html. This stylesheet demonstrates the use of xsl:for-each to convert a set of elements to an HTML table. |
Output XSL File XML File Download this sample
|
| |
|
|
| xsl:message SpokenLanguageMessage |
Displaying a message to the user.This stylesheet demonstrates the use of xsl:message to display a message to the user based on a condition. In this stylesheet, an user-friendly error message is displayed when a language that can not be handled is found. |
Output XSL File XML File Download this sample
|
| |
|
|
| xsl:message SpokenLanguageTerminate |
Displaying a message to the user. This stylesheet demonstrates the use of xsl:message to display a message to the user based on a condition. In this stylesheet, an error message is displayed when a language that can not be handled is found, followed by a termination of the transformation. |
Output Terminate Message XSL File XML File Download this sample
|
| |
|
|
| xsl:otherwise SpokenLanguages |
Displaying a message to the user. This stylesheet demonstrates the use of xsl:message to display a message to the user based on a condition. In this stylesheet, an error message is displayed when a language that can not be handled is found, followed by a termination of the transformation. |
Output XSL File XML File Download this sample
|
| |
|
|
| xsl:output EmployeesToHTML |
Displaying transformation output as HTML. This stylesheet processes a set of XML elements and displays the result in HTML. This is accomplished using the output method of HTML. |
Output XSL File XML File Download this sample
|
| |
|
|
| xsl:output EmployeesToText |
Displaying transformation output as Text. This stylesheet processes a set of XML elements and creates a resulting text file. This is accomplished using the output method of Text as shown above. In this example, we are taking the original xml elements and creating delimited text document sorted by name. |
Output XSL File XML File Download this sample
|
| |
|
|
| xsl:output EmployeesToXML |
Displaying transformation output as XML. This stylesheet processes a set of XML elements and displays the result in XML. This is accomplished using the output method of XMl as shown above. In this example, we are taking the original xml elements and creating a new xml document sorted by name. |
Output XSL File XML File Download this sample
|
| |
|
|
| xsl:param ListEmployeesTopLevel |
Using Top-level parameters. This stylesheet demonstrates the use of xsl:param to create an HTML table for elements for a specific department. Top-level parameters can be used for the stylesheet in cases where the same stylesheet will be called externally with different information. |
Output XSL File XML File Download this sample
|
| |
|
|
| xsl:param ListEmployeesWithParam |
Passing parameters to templates. This stylesheet demonstrates the use of the xsl:param element when passing parameters to a template. |
Output XSL File XML File Download this sample
|
| |
|
|
| xsl:sort SortByAmount |
Sorting elements by Amount. This stylesheet demonstrates the use of xsl:sort() by displaying employee information sorted by amount. |
Output XSL File XML File Download this sample
|
| |
|
|
| xsl:sort SortByDate |
Sorting elements by Date.This stylesheet demonstrates the use of xsl:sort() by displaying employee information sorted by date. |
Output XSL File XML File Download this sample
|
| |
|
|
| xsl:sort SortByName |
Sorting elements by Name. This stylesheet demonstrates the use of xsl:sort() on alphabetic text by displaying employee information sorted by name. |
Output XSL File XML File Download this sample
|
| |
|
|
| xsl:sort SortMultiKey |
Sorting elements by a Multi-part key. This stylesheet demonstrates the use of xsl:sort() by sorting Employee Information with Multi-part Keys. |
Output XSL File XML File Download this sample
|
| |
|
|
| xsl:variable ListEmployeesByDepartment |
Listing Employees per department/ This stylesheet demonstrates the use of xsl:variable to create an HTML table for elements for a specific department. The department that will be used for selection will be contained in a variable name $department. |
Output XSL File XML File Download this sample
|
| |
|
|