Read XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition Online
Authors: Michael Kay
Example 2: Non-Western Digits
This example shows how digits other than the Western digits 0–9 can be used. I will use the Indic Arabic digits (that is, the digits used in many Arabic countries, as distinct from the so-called Arabic digits used in the West):
Number | Format pattern | Result |
12345 | • (x0660) |
The digits will be output in the output XML or HTML file in the usual order (most significant digit first). Displaying the number correctly when it appears as part of text that runs from right to left is the job of the browser or other display software, and you shouldn't worry about it at the XSLT level.
Example 3: NaN and Infinity
This example shows how the exceptional numeric values NaN and Infinity can be shown, for example in a statistical table.
Number | Format pattern | Result |
number(‘a’) | any | Not Applicable |
1e0 div 0 | any | Out of Range |
-1e0 div 0 | any | -Out of Range |
See Also
format-number()
function in Chapter 13, page 788
xsl:document
The
Changes in 2.0
This instruction is new in XSLT 2.0. It should not be confused with the
Format
validation? = “strict” | “lax” | “preserve” | “strip”
type? = qname>
Position
Attributes
Name | Value | Meaning |
validation optional | strict , lax , preserve , or skip | Indicates whether and how the document should be subjected to schema validation |
type optional | Lexical QName | Identifies a type declaration (either a built-in type, or a user-defined type imported from a schema) against which the outermost element of the new document is to be validated |
The
type
and
validation
attributes are mutually exclusive: if one is present, the other must be absent. These attributes are available only with a schema-aware XSLT processor.
Content
A sequence constructor.
Effect
The following sections describe firstly how the content of the document node is constructed and secondly how document-level validation works.
The Content of the Document
The
The child nodes of the new document node are constructed in a process that is very similar to that used for constructing the content of an element node, described under
Although the XML specification requires a well-formed document to contain exactly one element node, optionally preceded or followed by comments and processing instructions, this restriction is not carried forward into the XDM data model. In XDM, a document node can contain any sequence of elements, text nodes, comments, and processing instructions (including an empty sequence) as its children. In fact, a document node can have any content that is allowed for an element node, except for the namespaces and attributes.
The process of forming the content of the document node is described below.
The first stage is to evaluate the sequence constructor contained in the
The way that the instructions in the sequence constructor are evaluated is described in the rules for each instruction; the items produced by each instruction are concatenated together (in the order in which the instructions appear in the stylesheet) to produce the final result sequence.
The second stage of the process is to use the result sequence delivered by evaluating the sequence constructor to create the content of the new document node. This process works as follows:
1.
If there are any atomic values in the sequence, they are converted to strings using the XPath casting rules.
2.
Any sequence of adjacent strings is converted to a single text node, using a single space as a separator between adjacent strings.
3.
If there is a document node in the sequence, then it is replaced in the sequence by its children (this may produce an arbitrary sequence of elements, text nodes, comments, and processing instructions).
4.
Adjacent text nodes within the sequence are combined into a single text node,
without
any space separator. Zero-length text nodes are removed completely.