Re: [xsl] problem with fn:contains using xsl:param

Subject: Re: [xsl] problem with fn:contains using xsl:param
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Sun, 13 Dec 2009 17:40:44 -0500
At 2009-12-13 20:12 +0100, Piotr Dobrogost wrote:
I'm using Saxon-HE to test XSLT 2.0 document I'm creating. The purpose of transformation is to generate Perl source code based on schema file.

I had this statement

<xsl:template match="xsd:element[contains(@type,'xsd:date') or contains(@type,'xsd:dateTime') or contains(@type,'xsd:bool')]">

which was working as expected and I wanted to refactor it to something like this

<xsl:param name="KnownXSDTypes">xsd:date xsd:dateTime xsd:bool</xsl:param>
<xsl:template match="xsd:element[contains($KnownXSDTypes, @type)]">

but after this change I'm getting different results. I don't see how the latter code could have different meaning than the former one.

Any ideas?

First "xsd:bool" is incomplete and would have to be "xsd:boolean".

And while it won't affect this particular example, the "protected" way of doing what you are doing with strings is to add a space at the start and end of your string with the tokens, and then add a space to the start and end of the token being searched.

In XSLT 2 you might consider something like:

  <xsl:param name="KnownXSDTypes" as="element()*">
  <xsl:template match="xsd:element[@type=$KnownXSDTypes]">

I hope this helps.

. . . . . . . . Ken

XSLT/XQuery/XPath training after 2010-03-15/19
Vote for your XML training:
Crane Softwrights Ltd.
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:
Video overview:
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Male Cancer Awareness Nov'07
Legal business disclaimers:

Current Thread