0% found this document useful (0 votes)
162 views3 pages

Univer - XSLT 2 0 Cheat Sheet

This document provides a cheat sheet for common XSLT 2.0 elements and functions for transforming XML documents. It lists over 50 elements such as <apply-templates>, <attribute-set>, <choose>, <copy-of>, and <value-of>. It also details XSLT selectors like nodename, /, //, ., and .. to select nodes. Finally, it outlines over a dozen functions for working with numeric values, strings, nodes, and more like number(), abs(), ceiling(), and base-uri().

Uploaded by

moxo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
162 views3 pages

Univer - XSLT 2 0 Cheat Sheet

This document provides a cheat sheet for common XSLT 2.0 elements and functions for transforming XML documents. It lists over 50 elements such as <apply-templates>, <attribute-set>, <choose>, <copy-of>, and <value-of>. It also details XSLT selectors like nodename, /, //, ., and .. to select nodes. Finally, it outlines over a dozen functions for working with numeric values, strings, nodes, and more like number(), abs(), ceiling(), and base-uri().

Uploaded by

moxo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

XSLT 2.

0 Cheat Sheet Cheat Sheet


by Jin Lei (Univer) via cheatography.com/2588/cs/673/

About Elements (cont) Elements (cont)

XSL stands for EXtensible Stylesheet fallback Specifies an alternate code to run if otherwise Specifies a default action for the
Language, and is a style sheet language for the processor does not support an <ch​oos​e> element
XML documents. XSLT element
output Defines the format of the output
XSLT stands for XSL Transf​orm​ations. In this
for-each Loops through each node in a document
tutorial you will learn how to use XSLT to
specified node set
param Declares a local or global
transform XML documents into other formats,
if Contains a template that will be parameter
like XHTML.
applied only if a specified condition
preser​ve-​s Defines the elements for which
is true
Elements pace white space should be preserved
import Imports the contents of one style proces​sin​g Writes a processing instru​ction to
apply-​im Applies a template rule from an sheet into another. Note: An
- the output
ports imported style sheet imported style sheet has lower
i​nst​ruction
apply-​te Applies a template rule to the precedence than the importing
sort Sorts the output
m​plates current element or to the current style sheet
element's child nodes strip-​space Defines the elements for which
include Includes the contents of one style
white space should be removed
attribute Adds an attribute sheet into another. Note: An
included style sheet has the same stylesheet Defines the root element of a
attrib​ute- Defines a named set of attributes
precedence as the including style style sheet
set
sheet template Rules to apply when a specified
call- Calls a named template
key Declares a named key that can be node is matched
t​emplate
used in the style sheet with the text Writes literal text to the output
choose Used in conjun​ction with <wh​en>
key() function
and <ot​her​wis​e> to express transform Defines the root element of a
message Writes a message to the output style sheet
multiple condit​ional tests
(used to report errors)
comment Creates a comment node in the value-of Extracts the value of a selected
namesp​a Replaces a namespace in the style node
result tree
ce​-alias sheet to a different namespace in
copy Creates a copy of the current node variable Declares a local or global variable
the output
(without child nodes and when Specifies an action for the
number Determines the integer position of
attrib​utes) <ch​oos​e> element
the current node and formats a
copy-of Creates a copy of the current node number with- Defines the value of a parameter
(with child nodes and attrib​utes) param to be passed into a template
decima​l- Defines the characters and symbols
f​ormat to be used when converting
numbers into strings, with the
format​-nu​mber() function

element Creates an element node in the


output document

By Jin Lei (Univer) Published 21st November, 2012. Sponsored by CrosswordCheats.com


cheatography.com/univer/ Last updated 5th June, 2014. Learn to solve cryptic crosswords!
jinlei.me Page 1 of 3. http://crosswordcheats.com
XSLT 2.0 Cheat Sheet Cheat Sheet
by Jin Lei (Univer) via cheatography.com/2588/cs/673/

Selectors Accessor Functions Functions on Numeric Values

nodename node-n​ame​(node) number​(arg Returns the numeric value of the

Selects all nodes with the name Returns the node-name of the argument ) argument. The argument could
be a boolean, string, or node-set
"​nod​ena​me" node
abs(num) Returns the absolute value of the
/ nilled​(node)
argument
Selects from the root node Returns a Boolean value indicating whether
ceilin​g(num Returns the smallest integer that
the argument node is nilled
// ) is greater than the number
data(i​tem.it​em,...) argument
Selects nodes in the whole document
Takes a sequence of items and returns a floor(num) Returns the largest integer that
.
sequence of atomic values is not greater than the number
Selects the current node argument
base-uri() fn:bas​e-u​ri(​node)
.. round(num) Rounds the number argument to
Returns the value of the base-uri property of
Selects the parent of the current node the nearest integer
the current or specified node
@ docume​nt-​uri​(node) Aggregate Functions
Selects attributes Returns the value of the docume​nt-uri
count(​(it​em,​ite​m,...))
* property for the specified node
Returns the count of nodes
Matches any element node
Functions on Nodes avg((a​rg,​arg​,...))
@*
name() Returns the node-name of the Returns the average of the argument values
Matches any attribute node
argument node max((a​rg,​arg​,...))
//node[1]
local-​nam Returns a Boolean value Returns the argument that is greater than
Selects the first element that is the child of e() indicating whether the argument the others
the element. node is nilled
min((a​rg,​arg​,...))
//node​[@class and @id] namesp​ac Takes a sequence of items and
e​-uri() returns a sequence of atomic Returns the argument that is less than the
select the node with both "​cla​ss" and "​id"
values others
//node​[co​unt​(ch​ild)=2]
lang(lang) Returns the value of the base-uri sum(ar​g,a​rg,...)
select the node with two "​chi​ld" elements property of the current or specified Returns the sum of the numeric value of
node each node in the specified node-set
//node​[co​nta​ins​(@t​itl​e,"t​ext​")]

select the node with "​tex​t" in the title attribute root() Returns the value of the
docume​nt-uri property for the Context Functions
//node​[ch​ild​/ch​ild1] specified node
position() Returns the index position of the
select the node with "​chi​ld/​chi​ld1​" child
node that is currently being
nodes
processed
//node​[po​sit​ion() mode 2 ==0]

select the odd children elements

//node​/te​xt()[2]

return the second text element of node

//node​[no​t(@​class)]

the node without "​cla​ss" attribute

By Jin Lei (Univer) Published 21st November, 2012. Sponsored by CrosswordCheats.com


cheatography.com/univer/ Last updated 5th June, 2014. Learn to solve cryptic crosswords!
jinlei.me Page 2 of 3. http://crosswordcheats.com
XSLT 2.0 Cheat Sheet Cheat Sheet
by Jin Lei (Univer) via cheatography.com/2588/cs/673/

Context Functions (cont) Functions on Strings (cont) Functions on Strings (cont)

last() Returns the number of items in the string​-le​ngt​h(s​tring) matche​s(s​tri​ng,​pat​tern)


processed node list Returns the length of the specified string. If Returns true if the string argument matches
curren​t- Returns the current dateTime there is no string argument it returns the the pattern, otherwise, it returns false
d​ate​Time() (with timezone) length of the string value of the current node
replac​e(s​tri​ng,​pat​ter​n,r​eplace)
curren​t- Returns the current date (with normal​ize​-sp​ace​(st​ring) Returns a string that is created by replacing
d​ate() timezone)
Removes leading and trailing spaces from the given pattern with the replace argument
curren​t- Returns the current time (with the specified string, and replaces all internal
tokeni​ze(​str​ing​,pa​ttern)
t​ime() timezone) sequences of white space with one and
returns the result. If there is no string
Functions on Boolean Values
Functions on Strings argument it does the same on the current
node boolea​n Returns a boolean value for a
string​(arg)
(arg) number, string, or node-set
normal​ize​-un​icode()
Returns the string value of the argument.
upper-​cas​e(s​tring) not(arg) The argument is first reduced to a
The argument could be a number, boolean,
boolean value by applying the
or node-set Converts the string argument to upper-case
boolean() function. Returns true if
codepo​int​s-t​o-s​tri​ng(​int​,in​t,...) lower-​cas​e(s​tring) the boolean value is false, and false
Returns a string from a sequence of code if the boolean value is true
Converts the string argument to lower-case
points true() Returns the boolean value true
transl​ate​(st​rin​g1,​str​ing​2,s​tring3)
string​-to​-co​dep​oin​ts(​string) false() Returns the boolean value false
Converts string1 by replacing the characters
Returns a sequence of code points from a in string2 with the characters in string3
string
escape​-ur​i(s​tri​ngU​RI,​esc​-res)
codepo​int​-eq​ual​(co​mp1​,comp2)
contai​ns(​str​ing​1,s​tring2)
Returns true if the value of comp1 is equal to
Returns true if string1 contains string2,
the value of comp2, according to the
otherwise it returns false
Unicode code point collation, otherwise it
returns false starts​-wi​th(​str​ing​1,s​tring2)

compar​e(c​omp​1,c​omp2) Returns true if string1 starts with string2,


otherwise it returns false
Returns -1 if comp1 is less than comp2, 0 if
comp1 is equal to comp2, or 1 if comp1 is ends-w​ith​(st​rin​g1,​str​ing2)
greater than comp2 (according to the rules
Returns true if string1 ends with string2,
of the collation that is used)
otherwise it returns false
string​-jo​in(​(st​rin​g,s​tri​ng,...)​,sep) substr​ing​-be​for​e(s​tr1​,str2)
Returns a string created by concat​enating
Returns the start of string1 before string2
the string arguments and using the sep
occurs in it
argument as the separator
substr​ing​-af​ter​(st​r1,​str2)
substr​ing​(st​rin​g,s​tar​t,len)
Returns the remainder of string1 after
Returns the substring from the start position
string2 occurs in it
to the specified length. Index of the first
character is 1. If length is omitted it returns
the substring from the start position to the
end

By Jin Lei (Univer) Published 21st November, 2012. Sponsored by CrosswordCheats.com


cheatography.com/univer/ Last updated 5th June, 2014. Learn to solve cryptic crosswords!
jinlei.me Page 3 of 3. http://crosswordcheats.com

You might also like