The root cause of this problem is that the optimizer isn't
recognizing that the result of <xsl:number> depends on the context node,
and it's therefore incorrectly moving it out of the <xsl:for-each>.
What happens next is somewhat bizarre, and is related to
the fact that the body of the for-each instruction doesn't return a result: it
exists solely for its side-effects. The empty() in the warning message is the
type calculated for the xsl:message instruction, which in turn becomes the type
of the entire xsl:for-each. Saxon is getting close to optimizing this entire
template out of existence, having worked out that it never produces any
principal output. Instead, it just produces this rather strange warning
Calling the document() function with a URL that's designed
to have side-effects is not a particularly good idea (see http://www.w3.org/2001/tag/doc/whenToUseGet.html ).
It's unpredictable whether and how often the document function will actually be
Using an xsl:variable whose select expression has
side-effects compounds the problem: a variable will only be evaluated if its
value is needed. Note in particular that the order of evaluating different
variables is not well-defined.
If you want to write code that exists only for
its side-effects, you have to adopt increasingly elaborate tricks to
persuade the optimizer that you are producing real output. At present, you could
fool the optimizer by writing say
<xsl:copy-of select="$sql-stat[position() + 1
within the <xsl:if> - but that won't necessarily work
Warning: Required item type of value of variable $0 is empty();
supplied value has item type empty(). The expression can succeed only if the
supplied value is an empty sequence.; SystemID: xsl/wf/save-index.xsl; Line#:
101; Column#: -1 in "xsl/wf/wf-main.xsl"
I don't understand what
this means and the actual line number is wrong. Line 101 is bolded below. The
message is not presented when the <xsl:message> element is
moved out of the <xsl:if>. I am definitely bewildered. And this
is in the stylesheet that fails with Too many nested
<xsl:call-template> calls error.
select="$task"> <!-- error line 101 -->
delete from tasks where
path='<xsl:number count="task" level="multiple"
<xsl:variable name="encoded-sql" select="escape-uri($sql, false())"/>
<xsl:message>Task index update error: <xsl:copy-of
Thanks again for
your attention. I really appreciate it.
------------------------------------------------------- The SF.Net
email is sponsored by: Beat the post-holiday blues Get a FREE limited edition
SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well,
_______________________________________________ saxon-help mailing list