[Accessibility conventions are described at the bottom of the page]
*** This is a free preview excerpt of a commercial publication. ***

7. Data type expressions and functions
[> 8.][< 6.0][^^^]
7.0 Data type expressions and functions
[> 8.][< 7.][^^][^^^]
Powerful functions and expression support
[[1] - this chapter describes functions and expressions to manipulate variables and values of data types
[[2] - the XSLT specification includes facilities implementing algorithms for publishing-oriented facilities so that the stylesheet writer doesn't have to
][1] - value manipulation
[[2] - boolean functions and operators
 [2] - number functions and operators
 [2] - string functions
 [2] - node set functions and operators
 [2] - [P2.0]sequence functions and operator
 [2] - [P2.0]date and time functions and operators
 [2] - [P2.0]item functions and operators
][1] - [P2.0]regular expressions
 [1] - [T2.0]string analysis
 [1] - access to the source node tree
[[2] - de-referencing pointers between information items
 [2] - setting up lookup tables to tree nodes
]]
This training material assumes xmlns:xs="http://www.w3.org/2001/XMLSchema" when referencing W3C Schema data types
Advanced techniques
[[1] - this chapter also describes an approach to walking the source node tree in search of information in such a way that is impossible through available pattern matching techniques.
]
The XPath keywords covered in this chapter are as follows.
[[1] - [|]
[[2] - union operator
][1] - [P2.0] [union]
[[2] - union operator
][1] - [P2.0] [intersect]
[[2] - intersection operator
][1] - [P2.0] [except]
[[2] - exception operator
][1] - [P2.0] [to]
[[2] - create a sequence of integers
][1] - [P2.0] [instance of ]
[[2] - testing the type of an item
][1] - [P2.0] [castable as ]
[[2] - testing the conversion of an item
][1] - [P2.0] [cast as ]
[[2] - converting an item to the given type
][1] - [P2.0] [treat as ]
[[2] - validating an item as a given type
][1] - [or]
[[2] - boolean operator
][1] - [and]
[[2] - boolean operator
][1] - [P2.0] [is << >>]
[[2] - document order comparison operators
][1] - [P2.0] [eq ne lt le gt ge]
[[2] - singleton value comparison operators
][1] - [= != < <= > >=]
[[2] - value comparison operators
][1] - [P2.0] [some every]
[[2] - quantified expressions
]]
The XSLT instructions covered in this chapter are as follows.
Instruction related to string formatting:
[[1] - [<xsl:decimal-format>]
[[2] - control the formatting of numbers when added to the result tree
]]
[T2.0]Instruction related to string analysis and regular expressions:
[[1] - [<xsl:analyze-string>]
[[2] - determine the matching components in an analysis of a string
][1] - [<xsl:matching-substring>]
[[2] - act on matching components from the analysis of a string
][1] - [<xsl:non-matching-substring>]
[[2] - act on non-matching components from the analysis of a string
]]
Instruction related to advanced access to the source node tree:
[[1] - [<xsl:key>]
[[2] - declare key nodes in the source tree node for bulk processing
]]
Instruction related to advanced algorithmic techniques:
[[1] - [<xsl:call-template>]
[[2] - use named templates with subroutine-like control
]]
The functions covered in this chapter are as follows.
Functions related to boolean data types:
[[1] - [boolean]()
[[2] - casting an argument to a boolean value
][1] - [false]()
[[2] - a fixed boolean value
][1] - [lang]()
[[2] - finding the in-scope language as specified by xml:lang=
][1] - [not]()
[[2] - inverting the boolean value of the argument
][1] - [true]()
[[2] - a fixed boolean value
]]
Functions related to number data types:
[[1] - [P2.0] [abs]()
[[2] - returning the absolute value
][1] - [ceiling]()
[[2] - rounding a number up
][1] - [floor]()
[[2] - rounding a number down
][1] - [number]()
[[2] - casting an argument to a number
][1] - [round]()
[[2] - rounding a number
][1] - [P2.0] [round-half-to-even]()
[[2] - rounding a number
]]
Functions related to string data types:
[[1] - [P2.0] [codepoint-equal]()
[[2] - Unicode string comparison
][1] - [P2.0] [codepoints-to-string]()
[[2] - Unicode string conversion
][1] - [P2.0] [compare]()
[[2] - string comparison
][1] - [concat]()
[[2] - string concatenation
][1] - [contains]()
[[2] - string detection
]]
[[1] - [P2.0] [default-collation]()
[[2] - obtaining the default collation
][1] - [P2.0] [ends-with]()
[[2] - establish the presence of a string
][1] - [format-number]()
[[2] - adding punctuation and controlling number display
][1] - [P2.0] [lower-case]()
[[2] - string case folding
][1] - [P2.0] [matches]()
[[2] - regular expression matching
][1] - [normalize-space]()
[[2] - normalizing extraneous spaces in a string
][1] - [P2.0] [normalize-unicode]()
[[2] - normalizing Unicode characters in a string
][1] - [P2.0] [replace]()
[[2] - regular expression replacement
][1] - [starts-with]()
[[2] - establishing the presence of a string
][1] - [string]()
[[2] - casting an argument to a string
][1] - [P2.0] [string-join]()
[[2] - join a sequence of strings into a single string
][1] - [string-length]()
[[2] - finding the length of a string
][1] - [P2.0] [string-to-codepoints]()
[[2] - Unicode string conversion
][1] - [substring]()
[[2] - returning a portion of a string
][1] - [substring-after]()
[[2] - returning a portion of a string
][1] - [substring-before]()
[[2] - returning a portion of a string
][1] - [P2.0] [tokenize]()
[[2] - regular expression tokenizing
][1] - [translate]()
[[2] - translating characters found in a string
][1] - [P2.0] [upper-case]()
[[2] - string case folding
]]
Functions related to sequences:
[[1] - [P2.0] [avg]()
[[2] - return the average of members of a numerical sequence
][1] - [count]()
[[2] - return a count of members of the sequence
][1] - [P2.0] [deep-equal]()
[[2] - return an indication of two sequences being identical
][1] - [P2.0] [distinct-values]()
[[2] - return a sequence with duplicate members removed
][1] - [P2.0] [empty]()
[[2] - return an indication of the sequence being empty
][1] - [P2.0] [exactly-one]()
[[2] - return an indication of the cardinality of a sequence
][1] - [P2.0] [exists]()
[[2] - return an indication of the sequence not being empty
][1] - [P2.0] [index-of]()
[[2] - return index pointers into a sequence
][1] - [P2.0] [insert-before]()
[[2] - return a sequence with members inserted
][1] - [P2.0] [max]()
[[2] - return the maximum value of the members of the numeric sequence
][1] - [P2.0] [min]()
[[2] - return the minimum value of the members of the numeric sequence
][1] - [P2.0] [one-or-more]()
[[2] - return an indication of the cardinality of a sequence
][1] - [P2.0] [remove]()
[[2] - return a sequence with a member removed
][1] - [P2.0] [reverse]()
[[2] - return the reverse of a sequence
][1] - [P2.0] [subsequence]()
[[2] - return a portion of a sequence
][1] - [sum]()
[[2] - return a sum of sequence members
][1] - [P2.0] [unordered]()
[[2] - return an unordered sequence
][1] - [P2.0] [zero-or-one]()
[[2] - return an indication of the cardinality of a sequence
]]
Functions related to date and time:
[[1] - [P2.0] [adjust-date-to-timezone]()
[[2] - return adjusted date
][1] - [P2.0] [adjust-dateTime-to-timezone]()
[[2] - return adjusted date and time
][1] - [P2.0] [adjust-time-to-timezone]()
[[2] - return adjusted time
][1] - [P2.0] [current-date]()
[[2] - return date/time component
][1] - [P2.0] [current-dateTime]()
[[2] - return date/time component
][1] - [P2.0] [current-time]()
[[2] - return date/time component
][1] - [P2.0] [dateTime]()
[[2] - return date/time component
][1] - [P2.0] [day-from-date]()
[[2] - return date/time component
][1] - [P2.0] [day-from-dateTime]()
[[2] - return date/time component
][1] - [P2.0] [days-from-duration]()
[[2] - return date/time component
][1] - [T2.0] [format-date]()
[[2] - format date string
][1] - [T2.0] [format-dateTime]()
[[2] - format date and time string
][1] - [T2.0] [format-time]()
[[2] - format time string
][1] - [P2.0] [hours-from-dateTime]()
[[2] - return date/time component
][1] - [P2.0] [hours-from-time]()
[[2] - return time component
][1] - [P2.0] [hours-from-duration]()
[[2] - return date/time component
][1] - [P2.0] [implicit-timezone]()
[[2] - return date/time component
]]
[[1] - [P2.0] [minutes-from-dateTime]()
[[2] - return date/time component
][1] - [P2.0] [minutes-from-duration]()
[[2] - return date/time component
][1] - [P2.0] [minutes-from-time]()
[[2] - return date/time component
][1] - [P2.0] [month-from-date]()
[[2] - return date/time component
][1] - [P2.0] [month-from-dateTime]()
[[2] - return date/time component
][1] - [P2.0] [months-from-duration]()
[[2] - return date/time component
][1] - [P2.0] [seconds-from-dateTime]()
[[2] - return date/time component
][1] - [P2.0] [seconds-from-duration]()
[[2] - return date/time component
][1] - [P2.0] [seconds-from-time]()
[[2] - return date/time component
][1] - [P2.0] [timezone-from-date]()
[[2] - return date/time component
][1] - [P2.0] [timezone-from-time]()
[[2] - return date/time component
][1] - [P2.0] [timezone-from-dateTime]()
[[2] - return date/time component
][1] - [P2.0] [year-from-date]()
[[2] - return date/time component
][1] - [P2.0] [year-from-dateTime]()
[[2] - return date/time component
][1] - [P2.0] [years-from-duration]()
[[2] - return date/time component
]]
Functions related to node data types:
[[1] - [P2.0] [base-uri]()
[[2] - obtaining a node's base URI
][1] - [P2.0] [data]()
[[2] - obtaining a node's data
][1] - [P2.0] [document-uri]()
[[2] - obtaining a node's document URI
][1] - [generate-id]()
[[2] - establishing uniqueness in source node trees
][1] - [local-name]()
[[2] - obtaining the local part of a node name
][1] - [name]()
[[2] - obtaining a node name
][1] - [namespace-uri]()
[[2] - obtaining the namespace URI for a node
][1] - [P2.0] [nilled]()
[[2] - obtaining a node's nilled status
][1] - [P2.0] [node-name]()
[[2] - obtaining a node name
][1] - [P2.0] [root]()
[[2] - obtaining the root node of a tree
][1] - [P2.0] [static-base-uri]()
[[2] - obtaining the static base URI
]]
Qualified name functions:
[[1] - [P2.0] [in-scope-prefixes]()
[[2] - return a set of prefixes
][1] - [P2.0] [local-name-from-QName]()
[[2] - return a local name
][1] - [P2.0] [namespace-uri-for-prefix]()
[[2] - return a namespace URI
][1] - [P2.0] [namespace-uri-from-QName]()
[[2] - return a namespace URI
][1] - [P2.0] [prefix-from-QName]()
[[2] - return a namespace prefix
][1] - [P2.0] [QName]()
[[2] - return a qualified name
][1] - [P2.0] [resolve-QName]()
[[2] - resolve a qualified name
]]
Other functions:
[[1] - [current]()
[[2] - current node access
][1] - [P2.0] [encode-for-uri]()
[[2] - return an encoded string
][1] - [P2.0] [escape-html-uri]()
[[2] - return an encoded string
][1] - [id]()
[[2] - accessing ID values in source node trees
][1] - [P2.0] [idref]()
[[2] - accessing references to ID values in source node trees
][1] - [P2.0] [iri-to-uri]()
[[2] - return an encoded string
][1] - [key]()
[[2] - accessing key nodes from key tables
][1] - [T2.0] [regex-group]()
[[2] - regular expression group retrieval
][1] - [P2.0] [resolve-uri]()
[[2] - return an absolute URI
]]

*** This is a free preview excerpt of a commercial publication. ***

This is an accessible version of Crane's commercial training material. The content has been specifically designed to assist screen reader software in viewing the entire textual content. Figures are replaced with text narratives.

Navigation hints are in square brackets:
[Tx.x] and [Fx.x] are textual representations of the applicability icons;
[digit] indicates list depth for nested lists;
[link [URL]] indicates the URL of a hyperlink if different than link;
[EXAMPLE] indicates an example listing of code;
[FIGURE] indicates the presence of a figure replaced by its description;
[>] jumps forward;
[<] jumps backward;
[^] jumps to start of the section;
[^^] jumps to the start of the chapter;
[^^^] jumps to the table of contents.
Suggestions for improvement are welcome: [info@CraneSoftwrights.com]
Book sales: [http://www.CraneSoftwrights.com/links/trn-acc.htm]
Information: [http://www.CraneSoftwrights.com/links/info-acc.htm]
This content is protected by copyright and, as there are no means to protect this accessible version from plagiarism, please do not make any commercial edition available to others.

+//ISBN 978-1-894049::CSL::Courses::PTUX//DOCUMENT Practical Transformation Using XSLT and XPath 2011-02-11 21:00UTC//EN
Practical Transformation Using XSLT and XPath
Fourteenth Edition - 2011-02-11
ISBN 978-1-894049-24-5
Copyright © Crane Softwrights Ltd.