list of characters appearing in a play.
247
Checking for Cycles in a Graph
This example provides a generic procedure to look for cycles in a graph, and then applies this procedure to a data file to see if the ID/IDREF links are cyclic. It illustrates the use of
to simulate a higher-order function.
251
Generating an Attribute Conditionally
This example shows the use of to generate an attribute only when certain conditions are true.
263
Deciding the Attribute Name at Runtime
This example shows the use of to generate an attribute whose name is not known until execution time.
264
Using an Attribute Set for Numbering
This stylesheet shows an unusual way of using attribute sets, to illustrate that the attributes generated by an attribute set do not need to have fixed values.
270
Using Recursion to Process a Sequence of Nodes
This example illustrates how to use a recursive named template to process a sequence of nodes. It uses this technique to find the longest speech in a play.
275
Using Recursion to Process a Sequence of Strings
This example uses a recursive named template to process a sequence of strings, obtained by splitting a line of text into its constituent words. It uses this technique to find phrases of the form “A and B”, where A and B are both the names of characters in a play.
278
Using for Repeated Output
This stylesheet uses to generate a standard table heading that appears repeatedly in the HTML output document (a listing of soccer matches).
294
Converting Attributes to Child Elements
This example illustrates how can be used to create element nodes whose names and content are taken from the names and values of attributes in the source document.
315
Showing the Ancestors of a Node
This example stylesheet can be applied to any XML document. For each element it processes all its ancestor elements, in reverse document order (that is, starting with the parent node and ending with the document element), and outputs their names to a comment that shows the position of the current node.
325
Single-Level Grouping by Value
This stylesheet uses to group a set of employees according to the department in which they work.
331
Multilevel Grouping by Value
This example groups employees by department, and groups the departments by location.
333
Grouping Consecutive Elements by Name
This example shows how the group-adjacent attribute of can be used to group adjacent elements having the same element name. It applies this technique to the adjacent and elements in a Shakespeare play.
336
Handling Repeating Groups of Adjacent Elements
This takes the previous example and makes the problem more difficult, by removing another layer of markup from the source document, so that it is necessary to infer multiple levels of hierarchic structure from the pattern of leaf elements in the tree.
338
Handling Flat XHTML Documents
This example shows how to use the group-starting-with attribute of to process the implicit structure of an XHTML source document, in which an element is followed by a number of elements that are logically subordinate to the element, but actually appear as its siblings.
340
Calculating Annual Leave
This is a simple illustration of the use of stylesheet functions to structure a computation in a stylesheet. It uses two user-defined functions, a function to calculate the annual leave entitlement of an employee, which in turn calls a function to calculate the employee's length of service given a starting and ending date.
347
Looking for Cycles Among Attribute Sets
This example illustrates the use of recursive stylesheet functions to analyze a graph structure. Specifically, it analyzes an XSLT stylesheet as its source document, to determine whether there are any cyclic dependencies among the attribute set definitions in the