Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 31st, 2013, 03:52 PM
Authorized User
 
Join Date: Jun 2013
Posts: 13
Thanks: 0
Thanked 1 Time in 1 Post
Default Migrate to XSLT 2.0 from 1.0

First off I apologize for knowing enough about xslt programming to probably be dangerous. That said, I continue to get many errors with 1.0, because apparently many functions (like Min, Max, Avg) are not available in 1.0. Thus I wish to consider moving to 2.0. What all would be involved in this? Thanks much for any advise or reference.
Jake

I'm running Win7, 64bit. Here's a sample of my .xsl.
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
<xsl:template match="/MissionProfile">
<html>
<h2>Here's your Dead Reckoning course variation in decimiles:</h2>
<body>
<xsl:for-each select="Gather/Stat">
<xsl:text>Number of course samples = </xsl:text>
<xsl:value-of select="count(Point)"/>
</xsl:for-each>
<br/>
<xsl:for-each select="Gather/Stat">
<xsl:text>Average course variation = </xsl:text>
<xsl:value-of select="sum(Point)"/>
</xsl:for-each>
<xsl:text> Decimiles </xsl:text>
<br/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
 
Old October 31st, 2013, 05:08 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

The vast majority of XSLT 1.0 stylesheets can be run under a 2.0 processor with no problems.

XSLT 2.0 processors have two modes, normal mode and 1.0 backwards compatibility mode. Backwards compatibility mode is active if the stylesheet specifies version="1.0". To some people's surprise, this does NOT stop you using 2.0 features such as the max() and min() functions. With backwards compatibility mode, transition problems are extremely unlikely; with 2.0 mode you might have to make a few changes, for example xsl:value-of when you select a set of nodes will show all the nodes, not only the first as in 1.0. My advice would be to move straight to 2.0 mode if you have sufficient test material to discover any such problems, but to stick with 1.0 mode if you have no test material or if you are simply more risk-averse.

There are detailed lists of incompatibilities in the XPath 2.0 and XSLT 2.0 specs, but they aren't really much use unless you know you stylesheet code extremely well, which would be unusual. Trial and error is a more common approach.

Some people find that the main effort in transition is not because of the change in language level from 1.0 to 2.0, but because of the change in processor. You may find that you were reliant on vendor extensions that are not supported by your 2.0 processor. If that's the case, you will have no choice but to fix the code (usually the vendor extension is something that's available as standard in 2.0, for example producing multiple output documents.)
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
 
Old October 31st, 2013, 05:15 PM
Authorized User
 
Join Date: Jun 2013
Posts: 13
Thanks: 0
Thanked 1 Time in 1 Post
Default

OK, thanks for that but I'm now only more confused! How exactly to I declare 2.0 so that I can use the min function? Do I need to download software? What? Thanks for your help.
 
Old October 31st, 2013, 06:01 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Oh dear, sorry, I was assuming too much knowledge.

The chances are that the XSLT processor you are currently using does not support XSLT 2.0. You've told us you're running Windows, but you haven't said how you are currently running your XSLT transformations, so we don't know what XSLT processor you are using.

To use XSLT 2.0 you will need to install an XSLT 2.0 processor, that is, a piece of software that understands the syntax of the XSLT 2.0 language and is capable of interpreting it or compiling it. The one to choose depends on your processing environment, e.g. client side or server side, Java or .NET. If you are looking for a free processor that isn't part of a larger product, the main choices are Saxon, Altova, and XMLPrime. There are some environments where it's still quite tricky to get XSLT 2.0 installed, for example PHP. If you're running in the browser, you can use the new Saxon-CE product.

You don't need to change anything in your stylesheet in principle, unless there are compatibility issues as I discussed in my previous answer.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Could not migrate proMRDS to MRS2008 kyubot BOOK: Professional Microsoft Robotics Studio ISBN: 978-0-470-14107-6 2 July 30th, 2009 12:14 PM
rake db:migrate error km.khalid006 RoR Ruby on Rails 0 July 27th, 2009 07:52 AM
treeview problem while migrate from 1.1 to 2.0 in nittin14 ASP.NET 2.0 Basics 2 September 8th, 2008 09:23 AM
migrate from unix to windows pmreddy01 Apache Tomcat 0 January 23rd, 2007 04:22 AM
Migrate application VS 2003 to VS 2005 rishi123 .NET Framework 1.x 0 December 28th, 2006 07:13 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.