Not your mothers XSLT (2.0 that is)
Just finished up the XSLT 2.0 talk it was really cool. Learned alot about what is going to be there. I wanted to hear more about the standardization of the extension stuff (i.e alt way to turn XML into Java instead of JAXB). But I'll have to ask aobut that later.
here are my notes
XPath and XSLT 2.0 are coming out together. XQuery is a new query language for XML and its based on XPath.
XPath was originally designed to be used with XSLT.
Each location is made up of a node test. @ sign moves to the attribute axis. Each element can evaluate to one or more elements. The return value is called a node set.
// means anywhere.
[] means predicate that is used to filter the node set its applied to. The predicate can evaluate Boolean expressions. There are also lots of functions available for use anywhere (including predicates). The function used in the example was count(node set).
XSLT defines how to reorganize data, to XML, HTML, plain text etc.
XSLT is divided into different templates
XSLT is a functional language, there are no local variables, all variables are global.
The templates are functions.
apply-templates means to go and find all the children of the current node and find templates that match and apply them.
apply-templates with an select attribute is like ‘find all the sub elements that match and apply any functions that are available for them.’
XSLT 2.0 goals
1) increase usability and readability
2) expand data-typing
3) simplify string manipulation – much simpler, reg-ex
4) add grouping functionality
5) allow multiple output docs
6) maintain backward compatibility – biggest goal, old style sheets should not break
XSLT 2.0 uses XML-Schema types – XSLT processors are not required to be ‘schema-aware’. 19 primitive built-in types 25 derived types.
Sequence – new collection type replaces node-set and result tree fragment.
Tons of cool date manipulation stuff, 10 types for date/time, 3 formatting functions, 21 extraction functions, 3 time-zone adjustment functions.
Saxon 7 is a preliminary impl of XSLT 2.0 does not yet support custom data types.
Sequences – an ordered list that can hold zero or more items, any of the data types that fit with XSLT. This will be the new result of and expression.
Every expression returns an expression.
<xsl:for-each select=”(1 to 100)[. Mod 5 = 0]”> outputs all the integers between 1 and 100 that are mod 5 = 0.
Dev-X Transform XML Document tool to show you the output.
Ordered with duplicates, the sequence will go in the order you specify instead of document order. I.e.. <xsl:for-each select=”(following-sibling::*[1], …./>
Since you put commas into the select attribute it will do the order you specify instead of document order.
Sequences are flattened, instead of nested sequences, the processor will flatten the nested elements into one long sequence.
The value of a sequence is the first element (so you can use a sequence with one value it will default to the simple thing of the only element.) If you specify a separator attribute in your xsl:value-of you will get the whole sequence. I.e. <xsl:value-of select=”(1 to 4)” separator=” + “/> will evaluate to “1 + 2 + 3 + 4”.
A sequence with one item is equivalent to the one item.
Expressions – iterative expressions ‘for $var in expression(, $var2 in expression) return expression’. There was some cool example stuff with subtotals and totals for a table of prices.
Conditional expressions inside XPath.
Comparitive Expressions

