recursal/MDN huggingface dataset:
For further reading
===================

« Transforming XML with XSLT

Print
-----

### Books

* **XSLT: Programmer's Reference, Second Edition**
    + **Author**: Michael H. Kay
    + **Length**: 992 pages
    + **Publisher**: Wrox; 2 edition (May 3, 2001)
    + **ISBN**: 0764543814
        - Michael Kay is a member of the W3C XSL Working Group and the developer of his own open-source XSLT processor, Saxon. He is also the author of the only book on this subject to have reached a second edition. This is a very big book, well laid out, and exhaustive, if sometimes exhausting, in detail, covering every possible base in the XSLT story.

https://www.amazon.com/XSLT-Programmers-Reference-Programmer/dp/0764543814

* **XSLT**
    + **Author**: Doug Tidwell
    + **Length**: 473 pages
    + **Publisher**: O'Reilly Media; 1 edition (August 15, 2001)
    + **ISBN**: 0596000537
        - Doug Tidwell is a senior developer at IBM and a prominent evangelist for XML technologies generally. He is the author of several articles and tutorials on various aspects of XML at IBM's extensive XML developer site. This book is somewhat less comprehensive than Michael Kay's, but it covers the basics well, and offers some intriguing examples.

https://www.amazon.com/Xslt-Doug-Tidwell/dp/0596000537

* **Learning XML, Second Edition**
    + **Author**: Erik T. Ray
    + **Length**: 432 pages
    + **Publisher**: O'Reilly Media; 2 edition (September 22, 2003)
    + **ISBN**: 0596004206
        - As the title indicates, this is an overview of XML generally. Chapter 6 is devoted specifically to XSLT.

https://www.amazon.com/gp/product/0596004206

Digital
-------

### Websites

* **World Wide Web Consortium**
    + **The W3C homepage**: https://www.w3.org
    + **The main XSL page**: https://www.w3.org/Style/XSL/
    + **XSLT specifications overview**: https://www.w3.org/TR/xslt/
    + **Archive of public style (CSS and XSLT) discussions**: https://lists.w3.org/Archives/Public/www-style/
    + **XPath specifications overview**: https://www.w3.org/TR/xpath/
        - The World Wide Web Consortium is the body that publishes Recommendations for a number of web-based technologies, many of which become the de-facto standard.
### Articles

* Hands-on XSL by Don R. Day
* What is XSLT? by G. Ken Holman
### Tutorials/Examples

* Jeni's XSLT Pages
* XMLPitstop.com
* XSL Tutorial
### Other

* Extensible Stylesheet Language (XSL)
* **XSL-List**
    + **Subscribe**: https://www.mulberrytech.com/xsl/xsl-list/index.html
    + **Archives**: https://www.biglist.com/lists/xsl-list/archives/
parent
======

The parent axis indicates the single node that is the parent of the context node. It can be abbreviated as two periods (`..`).
child
=====

The child axis indicates the children of the context node. If an XPath expression does not specify an axis, the child axis is understood by default. Since only the root node or element nodes have children, any other use will select nothing.
ancestor
========

The ancestor axis indicates all the ancestors of the context node beginning with the parent node and traveling through to the root node.
attribute
=========

The attribute axis indicates the attributes of the context node. Only elements have attributes. This axis can be abbreviated with the at sign (`@`).
following-sibling
=================

The following-sibling axis indicates all the nodes that have the same parent as the context node and appear after the context node in the source document.
self
====

The self axis indicates the context node itself. It can be abbreviated as a single period (`.`).
descendant-or-self
==================

The descendant-or-self axis indicates the context node and all of its descendants. Attribute and namespace nodes are **not** included - the parent of an attribute node is an element node, but attribute nodes are not the children of their parents.
preceding
=========

The preceding axis indicates all the nodes that precede the context node in the document except any ancestor, attribute, and namespace nodes.
preceding-sibling
=================

The preceding-sibling axis indicates all the nodes that have the same parent as the context node and appear before the context node in the source document.
following
=========

The following axis indicates all the nodes that appear after the context node, except any descendant, attribute, and namespace nodes.
ancestor-or-self
================

The ancestor-or-self axis indicates the context node and all of its ancestors, including the root node.
descendant
==========

The descendant axis indicates all of the children of the context node, and all of their children, and so forth. Attribute and namespace nodes are **not** included - the parent of an attribute node is an element node, but attribute nodes are not the children of their parents.
namespace
=========

The namespace axis indicates all the nodes that are in scope for the context node. In this case, the context node must be an element node.
<xsl:decimal-format>
====================

The `<xsl:decimal-format>` element defines the characters and symbols that are to be used in converting numbers into strings using the `format-number( )` function.

### Syntax


```xml
<xsl:decimal-format
 name=NAME
 decimal-separator=CHARACTER
 grouping-separator=CHARACTER
 infinity=STRING
 minus-sign=CHARACTER
 NaN=STRING
 percent=CHARACTER
 per-mille=CHARACTER
 zero-digit=CHARACTER
 digit=CHARACTER
 pattern-separator=CHARACTER />
```

### Required Attributes

None.

### Optional Attributes

`name`

Specifies a name for this format.

`decimal-separator`

Specifies the decimal point character. The default is (`.`).

`grouping-separator`

Specifies the thousands separator character. The default is (`,`).

`infinity`

Specifies the string used to represent infinity. The default is the string "`Infinity`".

`minus-sign`

Specifies the minus sign character. The default is the hyphen (`-`).

`NaN`

Specifies the string used when the value is not a number. The default is the string "`NaN`".

`percent`

Specifies the percentage sign character. The default is (`%`).

`per-mille`

Specifies the per thousand character. The default is (`‰`).

`zero-digit`

Specifies the digit zero character. The default is (`0`).

`digit`

Specifies the character used in the format pattern to stand for a digit. The default is (`#`).

`pattern-separator`

Specifies the character separating positive and negative subpatterns in a format pattern. The default is the semicolon (`;`).

### Type

Top-level, must be the child of `<xsl:stylesheet>` or `<xsl:transform>`.

### Defined

XSLT, section 12.3.

### Gecko support

Supported as of 1.0 (Mozilla 1.0, Netscape 7.0).
<xsl:with-param>
================

The `<xsl:with-param>` element sets the value of a parameter to be passed into a template.

### Syntax


```xml
<xsl:with-param name=NAME select=EXPRESSION>
  TEMPLATE
</xsl:with-param>
```

### Required Attributes

`name`

Gives this parameter a name.

### Optional Attributes

`select`

Defines the value of the parameter through an XPath expression. If the element contains a template, this attribute is ignored.

### Type

Subinstruction, always appears within an `<xsl:apply-templates>` or an `<xsl:call-template>` element.

### Defined

XSLT 11.6

### Gecko support

Supported.
<xsl:choose>
============

The `<xsl:choose>` element defines a choice among a number of alternatives. It behaves like a switch statement in procedural languages.

### Syntax


```xml
<xsl:choose>
  <xsl:when test="[whatever to test1]"></xsl:when>
  <xsl:when test="[whatever to test2]"></xsl:when>
  <xsl:otherwise></xsl:otherwise> [optional]
</xsl:choose>
```

### Required Attributes

None.

### Optional Attributes

None.

### Type

Instruction, appears with a template. It contains one or more `<xsl:when>` elements, and, optionally, a final `<xsl:otherwise>` element.

### Defined

XSLT, section 9.2.

### Gecko support

Supported.
<xsl:copy>
==========

The `<xsl:copy>` element transfers a shallow copy (the node and any associated namespace node) of the current node to the output document. It does not copy any children or attributes of the current node.

### Syntax


```xml
<xsl:copy use-attribute-sets=LIST-OF-NAMES>
  TEMPLATE
</xsl:copy>
```

### Required Attributes

None.

### Optional Attributes

`use-attribute-sets`

Lists attribute sets that should be applied to the output node, if it is an element. Names of the sets should be separated with whitespace characters.

### Type

Instruction, appears within a template.

### Defined

XSLT, section 7.5.

### Gecko support

Supported.
<xsl:sort>
==========

The `<xsl:sort>` element defines a sort key for nodes selected by `<xsl:apply-templates>` or `<xsl:for-each>` and determines the order in which they are processed.

### Syntax


```xml
<xsl:sort
 select=EXPRESSION
 order="ascending" | "descending"
 case-order="upper-first" | "lower-first"
 lang=XML:LANG-CODE
 data-type="text" | "number" />
```

### Required Attributes

None.

### Optional Attributes

`select`

Uses an XPath expression to specify the nodes to be sorted.

`order`

Specifies whether the nodes should be processed in "`ascending`" or "`descending`" order. The default is "`ascending`".

`case-order`

Indicates whether upper- or lowercase letters are to be ordered first. The allowable values are "`upper-first`" and "`lower-first`".

`lang`

Specifies which language is to be used by the sort.

`data-type`

Defines whether items are to be ordered alphabetically or numerically. The allowable values are "`text`" and "`number`" with "`text`" being the default.

### Type

Subinstruction, always appears as a child of <xsl:for-each>, where it must appear before the template proper or of <xsl:apply-templates>.

### Defined

XSLT, section10.

### Gecko support

Supported.
<xsl:transform>
===============

The `<xsl:transform>` element is exactly equivalent to the `<xsl:stylesheet>` element.

### Gecko support

Supported.
<xsl:for-each>
==============

The `<xsl:for-each>` element selects a set of nodes and processes each of them in the same way. It is often used to iterate through a set of nodes or to change the current node. If one or more `<xsl:sort>` elements appear as the children of this element, sorting occurs before processing. Otherwise, nodes are processed in document order.

### Syntax


```xml
<xsl:for-each select=EXPRESSION>
  <xsl:sort> [optional]
  TEMPLATE
</xsl:for-each>
```

### Required Attributes

`select`

Uses an XPath expression to select nodes to be processed.

### Optional Attributes

None.

### Type

Instruction, appears within a template.

### Defined

XSLT, section 8.

### Gecko support

Supported.
<xsl:fallback>
==============

The `<xsl:fallback>` element specifies what template to use if a given extension (or, eventually, newer version) element is not supported.

### Syntax


```xml
<xsl:fallback>
  TEMPLATE
</xsl:fallback>
```

### Required Attributes

None.

### Optional Attributes

None.

### Type

Instruction, appears within a template.

### Defined

XSLT, section 15

### Gecko support

Not supported at this time.
<xsl:import>
============

The `<xsl:import>` element is a top-level element that serves to import the contents of one stylesheet into another stylesheet. Generally speaking, the contents of the imported stylesheet have a lower import precedence than that of the importing stylesheet. This is in contrast to `<xsl:include>` where the contents of the included stylesheet have exactly the same precedence as the contents of the including stylesheet.

### Syntax


```xml
<xsl:import href=URI />
```

### Required Attributes

`href`

Specifies the URI of the stylesheet to import.

### Optional Attributes

None.

### Type

Top-level, must appear before any other child of `<xsl:stylesheet>` or `<xsl:transform>` in the importing stylesheet.

### Defined

XSLT, section 2.6.2.

### Gecko support

Mostly supported with a few issues with top level variables and parameters as of Mozilla 1.0.
<xsl:variable>
==============

The `<xsl:variable>` element declares a global or local variable in a stylesheet and gives it a value. Because XSLT permits no side-effects, once the value of the variable has been established, it remains the same until the variable goes out of scope

### Syntax


```xml
<xsl:variable name=NAME select=EXPRESSION >
  TEMPLATE
</xsl:variable>
```

### Required Attributes

`name`

Gives the variable a name.

### Optional Attributes

`select`

Defines the value of the variable through an XPath expression. If the element contains a template, this attribute is ignored.

### Type

Top-level or instruction. If it occurs as a top-level element, the variable is global in scope, and can be accessed throughout the document. If it occurs within a template, the variable is local in scope, accessible only within the template in which it appears.

### Defined

XSLT, section 11.

### Gecko support

Supported.
<xsl:when>
==========

The `<xsl:when>` element always appears within an `<xsl:choose>` element, acting like a case statement.

### Syntax


```xml
<xsl:when test=EXPRESSION>
  TEMPLATE
</xsl:when>
```

### Required Attributes

`test`

Specifies a boolean expression to be evaluated. If true, the contents of the element are processed; if false, they are ignored.

### Optional Attributes

None.

### Type

Subinstruction, always appears within an `<xsl:choose>` element.

### Defined

XSLT, section 9.2.

### Gecko support

Supported.
<xsl:stylesheet>
================

The `<xsl:stylesheet>` element (or the equivalent `<xsl:transform>` element) is the outermost element of a stylesheet.

### Namespace Declaration

A pseudo-attribute required to identify the document as an XSLT stylesheet. Typically this is `xmlns:xsl="http://www.w3.org/1999/XSL/Transform"`.

Syntax
------


```xml
<xsl:stylesheet
 version="NUMBER"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 id="NAME"
 extension-element-prefixes="LIST-OF-NAMES"
 exclude-result-prefixes="LIST-OF-NAMES">
    ENTIRE STYLESHEET
</xsl:stylesheet>
```

### Required Attributes

`version`

Specifies the version of XSLT required by this stylesheet.

### Optional Attributes

`exclude-result-prefixes`

Specifies any namespace used in this document that should not be sent to the output document. The list is whitespace separated.

`extension-element-prefixes`

Specifies a space-separated list of any namespace prefixes for extension elements in this document.

`default-collation`

Specifies the default collation used by all XPath expressions appearing in attributes or text value templates that have the element as an ancestor, unless overridden by another `default-collation` attribute on an inner element. It also determines the collation used by certain XSLT constructs (such as `<xsl:key>` and `<xsl:for-each-group>`) within its scope.

`default-mode`

Defines the default value for the `mode` attribute of all `<xsl:template>` and `<xsl:apply-templates>` elements within its scope.

`default-validation`

Defines the default value of the `validation` attribute of all relevant instructions appearing within its scope.

`expand-text`

Determines whether descendant text nodes of the element are treated as text value templates.

`id`

Specifies an `id` for this stylesheet. This is most often used when the stylesheet is embedded in another XML document.

`input-type-annotations`

Specifies whether type annotations are stripped from the element so the same results are produced whether the source documents have been validated against a schema or not.

`use-when`

Determines whether the element and all the nodes that have it as ancestor are excluded from the stylesheet.

`xpath-default-namespace`

Specifies the namespace that will be used if the element name is unprefixed or an unprefixed type name within an XPath expression.

### Type

Required outermost element of stylesheet.

Specifications
--------------

| Specification |
| --- |
| XSLT 3.0 # stylesheet-element |
<xsl:message>
=============

The `<xsl:message>` element outputs a message (to the JavaScript Console in NS) and optionally terminates execution of the stylesheet. It can be useful for debugging.

### Syntax


```xml
<xsl:message terminate="yes" | "no" >
  TEMPLATE
</xsl:message>
```

### Required Attributes

None.

### Optional Attributes

`terminate`

Set to "`yes`", indicates that execution should be terminated. The default value is "`no`", in which case the message is output and execution continues.

### Type

Instruction, appears within a template.

### Defined

XSLT, section 13.

### Gecko support

Supported.
<xsl:output>
============

The `<xsl:output>` element controls the characteristics of the output document. To function correctly in Netscape, this element, with the method attribute, must be used. As of 7.0, `method="text"` works as expected.

### Syntax


```xml
<xsl:output
 method="xml" | "html" | "text"
 version=STRING
 encoding=STRING
 omit-xml-declaration="yes" | "no"
 standalone="yes" | "no"
 doctype-public=STRING
 doctype-system=STRING
 cdata-section-elements=LIST-OF-NAMES
 indent="yes" | "no"
 media-type=STRING />
```

### Required Attributes

None.

### Optional Attributes

`method`

Specifies output format.

`version`

Specifies the value of the version attribute of the XML or HTML declaration in the output document. This attribute is only used when `method="html"` or `method="xml"`.

`encoding`

Specifies the value of the `encoding` attribute in the output document.

`omit-xml-declaration`

Indicates whether or not to include an XML declaration in the output. Acceptable values are "`yes`" or "`no`".

`standalone` (Not supported.)

If present, indicates that a standalone declaration should occur in the output document and gives its value. Acceptable values are "yes" or "no".

`doctype-public`

Specifies the value of the `PUBLIC` attribute of the `DOCTYPE` declaration in the output document.

`doctype-system`

Specifies the value of the `SYSTEM` attribute of the `DOCTYPE` declaration in the output document.

`cdata-section-elements`

Lists elements whose text contents should be written as `CDATA` sections. Elements should be whitespace separated.

`indent` (Not supported.)

Specifies if the output should be indented to indicate its hierarchic structure.

`media-type` (Not supported.)

Specifies the output document MIME type.

### Type

Top-level, must be the child `<xsl:stylesheet>` or `<xsl:transform>`.

### Defined

XSLT, section 16.

### Gecko support

Partial support. See comments above.
<xsl:namespace-alias>
=====================

The `<xsl:namespace-alias>` element is a rarely used device that maps a namespace in the stylesheet to a different namespace in the output tree. The most common use for this element is in generating a stylesheet from another stylesheet. To prevent a normally `xsl:`-prefixed literal result element (which should be copied as-is to the result tree) from being misunderstood by the processor, it is assigned a temporary namespace which is appropriately re-converted back to the XSLT namespace in the output tree.

### Syntax


```xml
<xsl:namespace-alias stylesheet-prefix=NAME result-prefix=NAME />
```

### Required Attributes

`stylesheet-prefix`

Specifies the temporary namespace.

`result-prefix`

Specifies the desired namespace for the output tree.

### Optional Attributes

None.

### Type

Top-level, must be the child of `<xsl:stylesheet>` or `<xsl:transform>`.

### Defined

XSLT, section 7.1.1

### Gecko support

Not supported at this time.
<xsl:comment>
=============

The `<xsl:comment>` element writes a comment to the output document. It must include only text.

### Syntax


```xml
<xsl:comment>
  TEMPLATE
</xsl:comment>
```

### Required Attributes

None.

### Optional Attributes

None.

### Type

Instruction, appears within a template.

### Defined

XSLT, section 7.4.

### Gecko support

Supported.
<xsl:if>
========

The `<xsl:if>` element contains a test attribute and a template. If the test evaluates to true, the template is processed. In this it is similar to an if statement in other languages. To achieve the functionality of an if-then-else statement, however, use the `<xsl:choose>` element with one `<xsl:when>` and one `<xsl:otherwise>` children.

### Syntax


```xml
<xsl:if test=EXPRESSION>
  TEMPLATE
</xsl:if>
```

### Required Attributes

`test`

Contains an XPath expression that can be evaluated (using the rules defined for `boolean( )` if necessary) to a Boolean value. If the value is true, the template is processed; if it is not, no action is taken.

### Optional Attributes

None.

### Type

Instruction, appears within a template.

### Defined

XSL section 9.1.

### Gecko support

Supported
<xsl:element>
=============

The `<xsl:element>` element creates an element in the output document.

### Syntax


```xml
<xsl:element name=NAME namespace=URI use-attribute-sets=LIST-OF-NAMES >
  TEMPLATE
</xsl:element>
```

### Required Attributes

`name`

Specifies the desired name of the output element. The name must be a valid QName.

### Optional Attributes

`namespace`

Specifies the namespace of the output element.

`use-attribute-sets`

A whitespace‐separated list of `attribute-set` element names to be applied to the `element` element's output element. Applied attributes can be overridden via nested `attribute` elements.

### Type

Instruction, appears within a template.

### Defined

XSLT, section 7.1.2.

### Gecko support

Supported.
<xsl:copy-of>
=============

The `<xsl:copy-of>` element makes a deep copy (including descendant nodes) of whatever the select attribute specifies to the output document.

### Syntax


```xml
<xsl:copy-of select=EXPRESSION />
```

### Required Attributes

`select`

Uses an XPath expression that specifies what is to be copied.

### Optional Attributes

None.

### Type

Instruction, appears within a template.

### Defined

XSLT, section 11.3.

### Gecko support

Supported.
<xsl:template>
==============

The `<xsl:template>` element defines an output producing template. This element must have either the match attribute or the name attribute set.

### Syntax


```xml
<xsl:template
 match=PATTERN
 name=NAME
 mode=NAME
 priority=NUMBER>
  <xsl:param> [optional]
  TEMPLATE
</xsl:template>
```

### Required Attributes

None.

### Optional Attributes

`match`

Specifies a pattern that determines the elements for which this template should be used. It is a required attribute if there is no `name` attribute.

`name`

Specifies a name for this template, by which it can be invoked through the `<xsl:call-template>` element.

`mode`

Specifies a particular mode for this template, which can be matched by an attribute of the `<xsl:apply-templates>` element. This is useful for processing the same information in multiple ways.

`priority`

Specifies a numeric priority for this template. This can be any number other than `Infinity`. The processor uses this number when more than one template matches the same node.

### Type

Top-level, must be the child of `<xsl:stylesheet>` or `<xsl:transform>`.

### Defined

XSLT, section 5.3.

### Gecko support

Supported.
<xsl:otherwise>
===============

The `<xsl:otherwise>` element is used to define the action that should be taken when none of the `<xsl:when>` conditions apply. It is similar to the `else` or `default` case in other programming languages.

### Syntax


```xml
<xsl:otherwise>
  TEMPLATE
</xsl:otherwise>
```

### Required Attributes

None.

### Optional Attributes

None.

### Type

Subinstruction, must appear as the last child of an `<xsl:choose>` element, within a template.

### Defined

XSLT, section 9.2

### Gecko support

Supported.