XML information pipe

Ihre Spezialisten für XML

Banner Werbung

XSLT 1.0 reference

The reference is based on the W3C recommendations XSL Transformations (XSLT)Version 1.0 and XML Path Language (XPath) 1.0. The language is available in modern Web browsers.

XSLT  |  elements

apply-imports | apply-templates | attribute | attribute-set | call-template | choose | comment | ceiling | copy | copy-of | decimal-format | element | fallback | for-each | if | import | include | key | message | namespace-alias | number | otherwise | output | param | preserve-space | processing-instruction | sort | strip-space | stylesheet | template | text | transform | value-of | variable | when | with-param


XSLT  |  attributes

case-order | cdata-section-elements | count | data-type | decimal-separator | digit | disable-output-escaping | doctype-public | doctype-system | elements | encoding | exclude-result-prefixes& | extension-element-prefix | format | from | grouping-separator | grouping-size | href | id | indent | infinity | etc etc etc.


XSLT  |  functions

boolean() | ceiling() | comment() | concat() | contains() | count() | current()& | document() | element-available() | false() | floor() | format-number() | function-available() | generate-id() | id() | key() | etc etc etc.


XSLT  |  expressions

!= | " " | > | >= | < | <= | " | () | * | + |  |  | :: | = | @* | [] | and | asix nodetest predicate | div | func() | mod | name | or | |


XSLT  |  axes

ancestor-or-self:: | ancestor:: | attribute:: | child:: | descendant-or-self:: | descendant:: | following-sibling:: | following:: | namespace:: | parent:: | preceding-sibling:: | preceding:: | self::


XSLT  |  elements


apply-imports

apply-imports

A  template> rule that is being used to override a <template> rule in an imported <stylesheet> can use the <apply-imports> element to invoke the overridden template rule.


Parent elements:

attribute | comment | copy | element | fallback | for-each | if | message | otherwise | param | processing-instruction | template | variable | when | with-param


Child elements:

--


Attributes:

--

Locate in the official documentation

XSLT  |  elements

apply-templates

apply-templates

In the absence of a @select attribute, the <apply-templates> instruction processes all of the children of the current node, including text nodes. However, text nodes that have been stripped will not be processed. If stripping of whitespace nodes has not been enabled for an element, then all whitespace in the content of the element will be processed as text, and thus whitespace between child elements will count in determining the position of a child element as returned by the position function.


A @select attribute can be used to process nodes selected by an expression instead of processing all children. The value of the @select attribute is an expression. The expression must evaluate to a node-set. The selected set of nodes is processed in document order, unless a <sort>ing specification is present.


Parent elements:

attribute | comment | copy | element | fallback | for-each | if | message | otherwise | param | processing-instruction | template | variable | when | with-param


Child elements:

sort | with-param


Attributes:

mode | select


Example 1:
XML source: <AAA>
   <BBB>10</BBB>
   <BBB>5</BBB>
   <BBB>7</BBB>
</AAA>
XSLT stylesheet: <xsl:stylesheet version = '1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

<xsl:output
method="text"/>

<xsl:template match="/">
   <xsl:apply-templates select="//BBB"/>
</xsl:template>

<xsl:template match="BBB">
   <xsl:text>BBB[</xsl:text>
   <xsl:value-of select="position()"/>
   <xsl:text>]:</xsl:text>
   <xsl:value-of select="."/>
</xsl:template>

</xsl:stylesheet>
Output txt.file: BBB[1]: 10
BBB[2]: 5
BBB[3]: 7

Example 2:
XML source: <AAA>
   <BBB>10</BBB>
   <BBB>5</BBB>
   <BBB>7</BBB>
</AAA>
XSLT stylesheet: <xsl:stylesheet version = '1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'>

<xsl:output
indent="yes"
method="xml">

<xsl:template match="/">
<AAA>
   <xsl:apply-templates select="//BBB"/>
   <xsl:apply-templates mode="xxx" select="//BBB"/>
   <xsl:apply-templates mode="yyy" select="//BBB"/>
   </AAA>
</xsl:template>

<xsl:template match="BBB">
   <OOO>
   <xsl:value-of select="."/>
   </OOO>
</xsl:template>

<xsl:template match="BBB" mode="xxx">
   <XXX>
   <xsl:value-of select="."/>
   </XXX>
</xsl:template>

<xsl:template match="BBB" mode="yyy">
   <YYY>
   <xsl:value-of select="."/>
   </YYY>
</xsl:template>

</xsl:stylesheet>
Output xml.file: <AAA>
   <OOO>10</OOO>
   <OOO>5</OOO>
   <OOO>7</OOO>
   <XXX>10</XXX>
   <XXX>5</XXX>
   <XXX>7</XXX>
   <YYY>10</YYY>
   <YYY>5</YYY>
   <YYY>7</YYY>
</AAA>
Locate in the official documentation

XSLT  |  elements


etc. etc. etc.



XSLT  |  attributes


case-order

case-order

This applies when @data-type="text", and specifies that upper-case letters should sort before lower-case letters or vice-versa respectively.

The default value is language dependent.


Values:

upper-first | lower-first


Default:

--


Elements:

sort

Locate in the official documentation

XSLT  |  attributes

cdata-section-elements

cdata-section-elements

@cdata-section-elements specifies a list of the names of elements whose text node children should be output using CDATA sections

Values:

--


Default:

--


Elements:

output

Locate in the official documentation

XSLT  |  attributes


etc. etc. etc.



XSLT  |  functions


boolean()

boolean boolean(object)

The boolean function converts its argument to a boolean as follows: a number is true if and only if it is neither positive or negative zero nor NaN, a node-set is true if and only if it is non-empty, a string is true if and only if its length is non-zero an object of a type other than the four basic types is converted to a boolean in a way that is dependent on that type

Locate in the official documentation

XSLT  |  functions

ceiling()

number ceiling(number)

The ceiling function returns the smallest (closest to negative infinity) number that is not less than the argument and that is an integer.

Locate in the official documentation

XSLT  |  functions


etc. etc. etc.



XSLT  |  expressions


!=

!=

If both objects to be compared are node-sets, then the comparison will be true if and only if there is a node in the first node-set and a node in the second node-set such that the result of performing the comparison on the string-values of the two nodes is true. If one object to be compared is a node-set and the other is a number, then the comparison will be true if and only if there is a node in the node-set such that the result of performing the comparison on the number to be compared and on the result of converting the string-value of that node to a number using the number function is true. If one object to be compared is a node-set and the other is a string, then the comparison will be true if and only if there is a node in the node-set such that the result of performing the comparison on the string-value of the node and the other string is true. If one object to be compared is a node-set and the other is a boolean, then the comparison will be true if and only if the result of performing the comparison on the boolean and on the result of converting the node-set to a boolean using the boolean function is true.


When neither object to be compared is a node-set and the operator is = or !=, then the objects are compared by converting them to a common type as follows and then comparing them. If at least one object to be compared is a boolean, then each object to be compared is converted to a boolean as if by applying the boolean function. Otherwise, if at least one object to be compared is a number, then each object to be compared is converted to a number as if by applying the number function. Otherwise, both objects to be compared are converted to strings as if by applying the string function. The = comparison will be true if and only if the objects are equal; the != comparison will be true if and only if the objects are not equal. Numbers are compared for equality according to IEEE 754 [IEEE 754]. Two booleans are equal if either both are true or both are false. Two strings are equal if and only if they consist of the same sequence of UCS characters.

Locate in the official documentation

XSLT  |  expressions

" "

" "

XPath expressions often occur in XML attributes. Within expressions, literal strings are delimited by single or double quotation marks, which are also used to delimit XML attributes. To avoid a quotation mark in an expression being interpreted by the XML processor as terminating the attribute value the quotation mark can be entered as a character reference (" or '). Alternatively, the expression can use single quotation marks if the XML attribute is delimited with double quotation marks or vice-versa.

Locate in the official documentation

XSLT  |  expressions


etc. etc. etc.



XSLT  |  axes


ancestor-or-self::

ancestor-or-self::

the ancestor-or-self axis contains the context node and the ancestors of the context node; thus, the ancestor axis will always include the root node

Locate in the official documentation

XSLT  |  axes

ancestor::

ancestor::

the ancestor axis contains the ancestors of the context node; the ancestors of the context node consist of the parent of context node and the parent's parent and so on; thus, the ancestor axis will always include the root node, unless the context node is the root node

Locate in the official documentation

XSLT  |  axes


etc. etc. etc.