[4suite] XSL Node-set parameter lost?
nico
nicolas.marsgui at libertysurf.fr
Fri Nov 3 17:11:58 MST 2006
On Fri, 3 Nov 2006 15:29:16 -0700 (MST), Mike Brown <mike at skew.org> wrote:
> nico wrote:
>> Hello,
>>
>> I use 4suite XML 1.0 to compile some docbook files, and have some
>> troubles
>> when using some node-sets in template parameters. The original XSL file
>> is
>> heavily stripped here to show the problem.
>>
>> The troublesome is when I do something like this, where the colspec
>> param
>> passed to the row template is a node-set:
>>
>> <xsl:template match="row" mode="newtbl">
>> <xsl:param name="colspec"/>
>
> Here you have defaulted $colspec to be an empty string if has not been
> passed in. I would default it to an empty node-set:
> <xsl:param name="colspec" select="/.."/>
Right, it would be more consistent. On the other hand, it could cause some
silent errors.
>> <xsl:variable name="entries">
>> <xsl:copy-of select="entry"/>
>> </xsl:variable>
>>
>> <i>
>> <xsl:value-of select="count($colspec/*)"/>
>> </i>
>> <xsl:apply-templates select="exsl:node-set($entries)" mode="newtbl">
>> <xsl:with-param name="colspec" select="$colspec"/>
>> </xsl:apply-templates>
>> </xsl:template>
>
> exsl:node-set($entries) returns a root node, because $entries is a root
> node.
>
> You do not have an explicit template matching a root node with
> mode="newtbl",
> so the built-in one is applied. The built-in one just calls
> apply-templates
> with no params. It does not acknowledge any params, so $colspec does not
> get
> passed on to the row template. The default kicks in. This is why you see
> the
> error.
Ah, ok. I then try:
<xsl:apply-templates select="exsl:node-set($entries)/*" mode="newtbl">
<xsl:with-param name="colspec" select="$colspec"/>
</xsl:apply-templates>
And it works fine. Thank you very much for the explanation!
> If xsltproc does not catch this, xsltproc is wrong :)
Yes, it's not the only thing where xsltproc is more "tolerant". Not sure
it's a good thing, though.
Regards,
BG
More information about the 4suite
mailing list