SourceForge has been redesigned. Learn more.

#248 SQL sample failing (empty sequence for $connection)

Michael Kay

When run as a standalone stylesheet, the sample
stylesheet illustrating the SQL extension fails with
the message:

Error at xsl:variable on line 26 of
XP0006: An empty sequence is not allowed as the value
of variable
Failed to compile stylesheet. 1 error detected.

I had some trouble pinning this one down, because the
stylesheet works when run as part of my test suite, but
fails in the way you describe when I run it standalone.

It turns out that the code that checks the namespace
for extension elements is assuming that the
"exslt:func" namespace is pre-allocated, and this is no
longer the case; the slot that was once used for this
namespace is now used for the first user-defined
namespace. As a result, if the first namespace
declaration loaded into the name pool is the namespace
of an extension element, it is not recognised as an
extension element namespace. You can therefore
circumvent the problem by adding the declaration
xmlns:dummy="dummy" before the xmlns:sql declaration.

The other part of the problem is that the stylesheet
attempts to fail cleanly if the SQL extension can't be
loaded, and this isn't working, because the type check
kicks in first. The system can tell that the
<xsl:fallback> code is going to return an empty
sequence, and that an empty sequence doesn't satisfy
the declared type of the variable, and it is therefore
failing at compile time rather than going on to execute
the xsl:fallback and the xsl:message at run-time. One
of these cases of the software being too clever by
half. I think the answer to this is to change the type
inferencing so that xsl:fallback has a type of item() -
i.e. no known static type; but to achieve this it has
to be retained in the expression tree: it is currently
optimized out before the type checking is done.

Source code (for the first problem) fixed. For the
second problem, for the time being I have changed the
type declaration in the sample stylesheet to allow an
empty sequence, and have raised questions in the the WG
about the spec in this area.

Michael Kay