What is related to upgrading from XSLT 1.0 to 2.0?
1 - What are the possible reasons for updating?
If you are an XSLT programmer, you will greatly benefit from the more convenient and expressive XSLT 2.0 + XPath 2.0 language and the new XDM (XPath data model).
You can take a look at this XSLT 2.0 Pluralsight course to get a solid and systematic view of the power of XSLT 2.0 .
You have:
Strong typing and all available types of XSD.
The ability to define your own (schema) types.
An XPath 2.0 sequence type that has no counterpart (just missing) in XPath 1.0.
The ability to define and write functions in pure XSLT is xsl:function instructions.
Range variables in XPath expressions ( for clause).
Much better and more powerful string processing. XPath 2.0 supports regular expressions in its tokenize() , matches() and replace() functions.
Much better and more powerful string processing - XSLT 2.0 support for regular expressions - xsl:analyze-string , xsl:matching-substring and xsl:non-matching-substring new XSLT.
More convenient, powerful and expressive grouping: xsl:for-each-group instruction.
Many new, very powerful XPath 2.0 features, such as date, time, and duration functions, just to name a few.
New XPath operators intersect , except , is , >> , << , some , every , instance of , castable as , ..., etc.
General XPath operators > , < , etc. Now they work on any ordered type of values ββ(not only on numbers, as in XPath 1.0).
Newer, safer value comparison operators: lt , le , eq , gt , ge , ne .
XPath 2.0 to statement, allowing you to have xsl:for-each select="1 to $N"
These and many other improvements / new features significantly increase the productivity of any XSLT programmer, which allows you to complete the development of XSLT 2.0 in a small part of the time required to develop the same modules with XSLT 1.0.
Strong typing allows many errors to be caught at compile time and immediately fixed. For me, this strong security is the biggest advantage of using XSLT 2.0.
2 - What are the possible reasons for NOT updating?
It is often possible, prudent and economical to leave existing, obsolete XSLT 1.0 applications intact and continue to use them with XSLT 1.0, while developing only new applications using XSLT 2.0.
Your leadership + any other non-technical reasons.
Having a lot of legacy XSLT 1.0 applications written in a bad style (for example, using the DOE functions or extensions that now need to be rewritten and the code will be reorganized).
An available XSLT 2.0 processor is missing.
3 - And finally, what are the steps to upgrade?
Change the version attribute of the xsl:stylesheet or xsl:transform element from "1.0" to "2.0" .
Remove all xxx:node-set() functions.
Remove any DOE.
Be prepared for the surprise that xsl:value-of now displays not only the first, but all elements of the sequence.
Try to use the new xsl:sequence statement as much as possible - use it to replace any xsl:copy-of instructions; use it instead of xsl:value-of at any time when the output type is not a string or text node.
Test carefully.
When testing verifies that the code is working as expected, start refactoring (if deemed necessary). It is recommended that you declare types for any variables, parameters, patterns, and functions. This can reveal new, hidden errors and their correction, improves the quality of your code.
If necessary, select which named templates to rewrite as xsl:function .
Decide if you need additional extension features that are used in the old version, or you can easily rewrite them using the powerful new XSLT features.
Concluding remarks . Not all of the above steps are necessary, and you can stop and declare a successful migration with zero error testing. It's much cleaner to start using all the features of XSLT 2.0 / XPath 2.0 in new projects.
Dimitre Novatchev Feb 22 2018-12-12T00: 00Z
source share