RE: [xsl] Passing xs:string containing zero characters

Subject: RE: [xsl] Passing xs:string containing zero characters
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 19 May 2010 09:17:59 +0100
The most likely explanation is that the second template is being called from
somewhere other than the first apply-templates instruction. Of course, I've
no idea whether that theory is plausible without seeing your source document
and the rest of the stylesheet.

One thing to watch out for is that a template rule can be called implicitly
by the built-in template rule for its parent element - such a template
implicitly passes on the parameters that it was called with.

There are a number of debuggers that can help with this kind of problem,
e.g. in Stylus Studio or Oxygen; or the trace output produced by Saxon's -T
option when running from the command line can pin it down quite quickly.

The error means that there was no xsl:with-param on the invoking
xsl:apply-templates for the relevant parameter name. The actual value of the
parameter is irrelevant; if you passed something inappropriate (e.g. an
empty sequence) you would get a different error.

Regards,

Michael Kay
http://www.saxonica.com/
http://twitter.com/michaelhkay 

> -----Original Message-----
> From: Toshihiko Makita [mailto:tmakita@xxxxxxxxx] 
> Sent: 19 May 2010 02:01
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] Passing xs:string containing zero characters
> 
> Hi!
> 
> I'm new to XSLT 2.0 and using it with Saxon 9.1 in DITA-Open Toolkit.
> I wrote following variable and pass it as a parameter as 
> $prmLang to the template.
> 
> <xsl:variable name="lang" as="xs:string" select="string(@xml:lang)"/>
> 
> <xsl:apply-templates select="child::*[contains(@class, ' 
> topic/related-links ')]">
>    <xsl:with-param name="prmLang" as ="xs:string" 
> select="$lang"/> </xsl:aplly-templates>
> 
> <xsl:template match="*[contains(@class, ' topic/related-links ')]">
>    <xsl:param name="prmLang" as="xs:string" required="yes"/>
>    ...
> </xsl:template>
> 
> Then the following error is occured when $lang is empty string.
> 
> "[xslt] 
> D:\DITA-OT1.5-FB\demo\xxx\xsl\xxx_dita2fo_relatedlinks.xsl:34: 
> Fatal Error! No value supplied for required parameter"
> 
> Is it a right behavior? I thought that xs:string can contain 
> any sequence of zero or more characters.
> 
> (If I rewrite the template code required="yes" to 
> select="''", then it works fine.)
> 
> Toshihiko Makita

Current Thread