XML information pipe
Ihre Spezialisten für XML
The reference is based on the W3C recommendations XSL Transformations (XSLT) Version 2.0, XML Path Language (XPath) 2.0, and XQuery 1.0 and XPath 2.0 Functions and Operators.
Standard excerpt:
XSLT 2.0 is a revised version of the XSLT 1.0 Recommendation.
XSLT 2.0 is designed to be used in conjunction with XPath 2.0. XSLT shares the same data model as XPath 2.0 and it uses the library of functions and
operators defined in Functions and Operators.
XSLT 2.0 also includes optional facilities to serialize the results of a transformation, by means of an interface to the serialization component
described in XSLT and XQuery Serialization.
analyze-string | apply-imports | apply-templates | attribute | call-template | character-map | choose | comment | copy | copy-of | decimal-format | element | fallback | for-each | for-each-group | function | if | import | import-schema | include | key | matching-substring | message | namespace | namespace-alias | next-match | non-matching-substring | number | otherwise | output | output-character | param | perform-sort | preserve-space | processing-instruction | result-document | etc etc etc.
as | byte-order-mark | case-order | cdata-section-elements | character | collation | copy-namespaces | count | data-type | decimal-separator | default-collation | default-validation& | digit | disable-output-escaping | doctype-public | doctype-system | elements | encoding | escape-uri-attributes | exclude-result-prefixes | etc etc etc. | etc etc etc.
abs | adjust-date-to-timezone | adjust-dateTime-to-timezone | adjust-time-to-timezone | attribute | avg | base-uri& | boolean | ceiling | codepoint-equal | codepoint-to-string | collection | comment | compare | concat | contains | etc etc etc.
!= | >>= | >> | >= | < | << | <= | (::) | * | + | | − | . | .. | ⁄⁄ | = | @ | [] | and | cast as | castabel as | div | eq | every..in..satisfies | except | for..in..return
ancestor | ancestor-or-self | attribute | child | descendant | descendant-or-self | following | following-sibling | namespace | parent | preceding | preceding-sibling | self
Built-in types | Number to String Conversion Attributes | Picture string | Regexp flags
analyze-string
analyze-string
The xsl:analyze-string instruction takes as input a string (the result of evaluating the expression in the select attribute) and a regular expression. The xsl:analyze-string instruction starts at the beginning of the input string and attempts to find the first substring that matches the regular expression. If there are several matches, the first match is defined to be the one whose starting position comes first in the string. If several alternatives within the regular expression both match at the same position in the input string, then the match that is chosen is the first alternative that matches.
Parent elements:
attribute | comment | copy | document element | fallback | for-each | for-each-group | function | if | key | message | namespace | otherwise | param | perform-sort | processing-instruction | result-document | sort | template | value-of | variable | when | with-param
Child elements:
fallback matching-substring snon-matching-substring
Attributes:
| XML source: |
<bbb>How do you do?<bbb> |
| XSLT stylesheet: | <xsl:stylesheet version = '2.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:output method="xml"/> indent="yes"/> omit-xml-declaration="yes"/> <xsl:template match="/aaa"> <xsl:analyze-string regex="\s" select="bbb"> <xsl:non-matching-substring> <aaa> <xsl:value-of select="."/> </aaa> </xsl:non-matching-substring> </xsl:analyze-string> </xsl:stylesheet> |
| Output xml.file: |
<aaa>How<aaa> <aaa>do<aaa> <aaa>you<aaa> <aaa>do?<aaa> |
apply-imports
apply-imports
A template rule that is being used to override another template rule can use the xsl:apply-imports or xsl:next-match instruction to invoke the overridden template rule. The xsl:apply-imports instruction only considers template rules in imported stylesheet modules; the xsl:next-match instruction considers all other template rules of lower import precedence and/or priority.
Parent elements:
attribute | comment | copy | document element | fallback | for-each | for-each-group | function | if | key | message | namespace | otherwise | param | perform-sort | processing-instruction | result-document | sort | template | value-of | variable | when | with-param
Child elements:
Attributes:
--
| XML source: |
<aaa> <bbb><bbb> <ccc><ccc> <aaa> |
| XSLT stylesheet: | <xsl:stylesheet version = '2.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:import href="st5-a.xslt"/> <xsl:output method="xml"/> indent="yes"/> omit-xml-declaration="yes"/> <xsl:template match="/aaa"> <xxx> <xsl:apply-templates select="*"/> </xxx> </xsl:template> <xsl:template match="bbb"> <main-bbb> <xsl:apply-imports/> </main-bbb> </xsl:template> </xsl:stylesheet> |
| Output xml.file: |
<xxx> <main-bbb> <imported-bbb/> </main-bbb> <imported-ccc/> <xxx> |
as
as
<template>: If an as attribute is present, the as attribute defines the required type of the result.
<variable>: specifies the required type of the variable
<param>: specifies the required type of the parameter
<with-param>: It is possible to have an as attribute on the xsl:with-param element that differs from the as attribute on the corresponding xsl:param element describing the formal parameters of the called template. In this situation, the supplied value of the parameter will first be processed according to the rules of the as attribute on the xsl:with-param element, and the resulting value will then be further processed according to the rules of the as attribute on the xsl:param element.
<function>: the required type of the result of the function
Values:
Default:
--
Elements:
function | param | template | variable | with-param
| XML source: | <aaa/> |
| XSLT stylesheet: | <xsl:stylesheet exclude-result-prefixes="my sch" version="2.0" xmlns:my="myFunctions" xmlns:sch="http://www.w3.org/2001/XMLSchema" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml"/> indent="yes"/> omit-xml-declaration="yes"/> <xsl:function as="sch:integer" name="my:return-number"> <aaa>10</aaa> </xsl:function> <xsl:function name="my:return-node"> <aaa>10</aaa> </xsl:function> <xsl:template match="/aaa"> <xxx> <xsl:copy-of select="my:return-node()"/> </xxx> <yyy> <xsl:copy-of select="my:return-number()"/> </yyy> </xsl:template> </xsl:stylesheet> |
| Output xml.file: |
<xxx> <aaa>10</aaa> </xxx> <yyy>10</yyy> |
byte-order-mark
byte-order-mark
<result-document>: The byte-order-mark attribute defines whether a byte order mark is written at the start of the file. If the value yes is specified, a byte order mark is written; if no is specified, no byte order mark is written. The default value depends on the encoding used. If the encoding is UTF-16, the default is yes; for UTF-8 it is implementation-defined, and for all other encodings it is no. The value of the byte order mark indicates whether high order bytes are written before or after low order bytes; the actual byte order used is implementation-dependent , unless it is defined by the selected encoding.
<output>: The byte-order-mark attribute defines whether a byte order mark is written at the start of the file. If the value yes is specified, a byte order mark is written; if no is specified, no byte order mark is written. The default value depends on the encoding used. If the encoding is UTF-16, the default is yes; for UTF-8 it is implementation-defined, and for all other encodings it is no. The value of the byte order mark indicates whether high order bytes are written before or after low order bytes; the actual byte order used is implementation-dependent , unless it is defined by the selected encoding.
Values:
Default:
--
Elements:
Locate in the official documentationabs
abs($arg)
$arg: numeric
returns: numeric
Returns the absolute value of $arg. If $arg is negative returns -$arg otherwise returns $arg. If type of $arg is one of the four numeric types xs:float, xs:double, xs:decimal or xs:integer the type of the result is the same as the type of $arg. If the type of $arg is a type derived from one of the numeric types, the result is an instance of the base numeric type.
| Input: | abs(10.5) |
| Output: | 10.5 |
| Input: | abs(-10.5) |
| Output: | 10.5 |
adjust-date-to-timezone
adjust-date-to-timezone($timezone)
$timezone: xs:date
returns: xs:date
Adjusts an xs:date value to a specific timezone, or to no timezone at all. If $timezone is the empty sequence, returns an xs:date without a timezone. Otherwise, returns an xs:date with a timezone. For purposes of timezone adjustment, an xs:date is treated as an xs:dateTime with time 00:00:00.
| Input: | adjust-date-to-timezone(xs:date("2002-03-07")) |
| Output: | 2002-03-07-05:00 |
| Input: | adjust-date-to-timezone(xs:date("2002-03-07-07:00")) |
| Output: | 2002-03-07-05:00 |
| Input: | adjust-date-to-timezone(xs:date("2002-03-07"), $tz) |
| Output: | 2002-03-07-10:00 |
!=
!=
Not Equal. General comparisons are existentially quantified comparisons that may be applied to operand sequences of any length. When evaluating a general comparison in which either operand is a sequence of items, an implementation may return true as soon as it finds an item in the first operand and an item in the second operand that satisifies the condition. != is not inverse of =.
| Input: | (1, 2) != (2, 3) |
| Output: | true |
| Input: | (2, 3) != (3, 4) |
| Output: | true |
| Input: | (1, 2) != (3, 4) |
| Output: | true |
>
>
Greater then. General comparisons are existentially quantified comparisons that may be applied to operand sequences of any length. When evaluating a general comparison in which either operand is a sequence of items, an implementation may return true as soon as it finds an item in the first operand and an item in the second operand that satisifies the condition.
Locate in the official documentationancestor
ancestor
It contains the ancestors of the context node (the parent, the parent of the parent, and so on). The ancestor axis includes the root node of the tree in which the context node is found, unless the context node is the root node.
This is a reverse axis. When using predicates with a sequence of nodes selected using a reverse axis, it is important to remember that the context positions for such a sequence are assigned in reverse document order.
ancestor-or-self
ancestor-or-self
The context node and the ancestors of the context node; thus, the ancestor-or-self axis will always include the root node This is a reverse axis. When using predicates with a sequence of nodes selected using a reverse axis, it is important to remember that the context positions for such a sequence are assigned in reverse document order.
Locate in the official documentationBuilt-in types
Built-in types
Number to String Conversion Attribute
Number to String Conversion Attribute
| 1: | 0 1 2 ... 10 11 12 ... |
| 01: | 00 01 02 ... 09 10 11 12 ... 99 100 101 |
| ١: | (Arabic-Indic digit one) ١ then ٢ then ٣ |
| A: | A B C ... Z AA AB AC ... |
| a: | a b c ... z aa ab ac ... |
| i: | i ii iii ... iv v vii viii ix x ... |
| I: | I II III IV V VI VII IX X ... |
| w: | generates numbers written as upper-case words, for example in English, ONE TWO THREE FOUR ... |
| Ww: | generates numbers written as title-case words, for example in English, One Two Three Four ... |
Picture string
Picture string
| Y: | year (absolute value) |
| M: | month in year |
| D: | day in month |
| etc. etc. etc. | etc. etc. etc. |
Regexp flags
Regexp flags
s: the match operates in "dot-all" mode. (Perl calls this the single-line mode.) If the s flag is not specified, the meta-character . matches any character except a newline (#x0A) character. In dot-all mode, the meta-character . matches any character whatsoever.
m: the match operates in multi-line mode. By default, the meta-character ^ matches the start of the entire string, while $ matches the end of the entire string. In multi-line mode, ^ matches the start of any line (that is, the start of the entire string, and the position immediately after a newline character), while $ matches the end of any line (that is, the end of the entire string, and the position immediately before a newline character). Newline here means the character #x0A only.
i: the match operates in case-insensitive mode.
x: whitespace characters (#x9, #xA, #xD and #x20) in the regular expression are removed prior to matching with one exception: whitespace characters within character class expressions (charClassExpr) are not removed. This flag can be used, for example, to break up long regular expressions into readable lines.