xsl-list
[Top] [All Lists]

Re: [xsl] Upgrading version should lead to bug - right?

2012-09-13 02:33:26
On 13 September 2012 08:16, Ihe Onwuka 
<ihe(_dot_)onwuka(_at_)googlemail(_dot_)com> 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?

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.

You are passing a sequence of more than one item to a function that
expects only 1.  When running xslt 1.0 'first item semantics' means in
that situation the first item in the sequence is used and the rest are
ignored.  In 2.0 thankfully that doesn't happen and you get the error.

It's hard to give an exact answer without seeing a small complete
runnable example, but the usual technique is to change

contains($foo, '...

to

for $x in $foo return contains($x, '....

or

$foo/contains(., '....




-- 
Andrew Welch
http://andrewjwelch.com

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>