I like this one
replace($input, '[^a-z0-9]+', '-', 'i')
more generl and avoids the problem all together ;-)
what does that 'i' and the end do? I thought replace only had 3
parameters.
I wasn't able to get any of the quote options in the replace to work,
not sure what I'm doing wrong there, so this one gets the job done.
..dan
On 2025-05-13 12:19, Liam R. E. Quin liam@xxxxxxxxxxxxxxxx wrote:
On Tue, 2025-05-13 at 18:40 +0000, dvint@xxxxxxxxx wrote:
much working
<xsl:function name="ping:gen_id">
<xsl:param name="INSTRING"/>
<xsl:value-of select="translate(replace(lower-
case($INSTRING), ' ',
'_'),
':()','')"/>
</xsl:function>
you could use translate() twice here of course.
translate($input, ' ', '_')
often i use replace($input, '[^a-z0-9]+', '-', 'i')
for generating IDs (and then fix them up to be unique), since e.g.
allowing % or < or > or & can also cause interesting problems :)
select="translate($inputString,
'', '')" />
\xA0\xA0\xA0\xA0 <xsl:value-of select="$outputString" />
Your problem here is after the XML parser converts ' to ' the
XPath processor sees,
translate($inputstring, '', '')
which is not what you want at all.
select="translate($inputString, "'", '')
will turn into
translate($inputString, "'", '')
which is what i think you want.
|