[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Upgrading version should lead to bug - right?

Subject: Re: Upgrading version should lead to bug - right?
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Thu, 13 Sep 2012 08:38:51 +0100
Re:  Upgrading version should lead to bug - right?
On 13/09/2012 08:16, Ihe Onwuka wrote:
I have an XSLT 1.0 stylesheet that has been running on an XSLT 2.0
processor no problem but barfs when you upgrade the version attribute
(no other change to the code) to 2.0.

That shouldn't happen right?
No, it's entirely possible that it will happen. Once you set the version attribute to 2.0, you enable XSLT 2.0's stronger type checking. For example, in XSLT 1.0, contains(author, "abc") works fine if there is more than one author (it just takes the first, and ignores the others), while XSLT 2.0 gives you the type error that you are reporting.

If the stylesheet author's intent was to select the first item and ignore the others (a common example is contains(following-sibling::*, "xyz")) then the fix is to make this explicit: change it to contains(following-sibling::*[1], "xyz"). But sometimes, when you look at the code, you realize that the stylesheet author simply didn't take into account the possibility that the expression might select more than one node.

I've not pinned down the precise line of offending code but the error I am getting is

A sequence of more than one item is not allowed as the first argument
of contains() ("_IOS, _WEB, _CTV", "_IOS, _WEB, _CTV", ...)

Now the input XML has elements like this

<m__category>_IOS, _WEB, _CTV</m__category>

so I wonder if the processor is parsing that element as a sequence
instead of as a comma separated string.
No, your first argument to contains() has selected more than one string. The first string is "_IOS, _WEB, _CTV", the second string is exactly the same, and subsequent strings (if they exist) are not listed in the error message.

Michael Kay
Saxonica

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.