Re: Does this XSLT 2.0 stylesheet use any XSLT 2.0 fe
2008/9/26 Jonathan Robie <jonathan.robie@xxxxxxxxxx>: > David Carlisle wrote: >> >> But my experience that it's quite esy to have documents that work in 1.0 >> but that generate an error in 2.0 (even if version="1.0") but that you >> have to try quite hard to accidentally have a stylesheet that produces >> non-error results that are necessarily different in version 1 and >> version 2 (although it's easy to generate test examples where the >> behaviour is different, just by looking at the appendix that lists the >> limits of compatibility mode.) > > The difference that is causing all the trouble seems to be the difference in > path expressions like this: > > <xsl:variable name="lang-id" select="/g:grammar/g:language/@id"/> > > If there are two g:language elements, an XSLT 1.0 processor returns only one > id attribute, and an XSLT 2.0 processor returns two. If the result is put > into the output then you get funny results. The variable will hold both attributes, it's when you pass it to something that only expects a single value that the first is chosen. For example: <xsl:value-of select="$lang-id"/> will return just the first, but if you did: <xsl:for-each select="$lang-id"> <xsl:value-of select="."/> ...then you would get both. > Unfortunately, this happens in at least several places in at least several > stylesheets, and I doubt there's any easy way to automatically detect where > the difference in behavior might cause different output for sample input or > for input governed by a given schema. That's the problem with 1.0.... the first time you get to know there's a problem is when the output is wrong. However, you could argue that it's poor form for the stylesheet writer to rely on the first item semantics, rather than explicitly selecting the first (eg /g:language/@id ) but they might not have known what was going on, or the cardinality of the <g:language> might have changed after the stylesheet was written etc.. If you have the choice, use 2.0 every time. -- Andrew Welch http://andrewjwelch.com Kernow: http://kernowforsaxon.sf.net/
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format