|
Subject: Re: [xsl] Creating strings with apos and replacing From: "Liam R. E. Quin liam@xxxxxxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> Date: Tue, 13 May 2025 19:19:21 -0000 |
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,
> '', '')" />
> B B B B <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.
--
Liam Quin,B https://www.delightfulcomputing.com/
Available for XML/Document/Information Architecture/XSLT/
XSL/XQuery/Web/Text Processing/A11Y training, work & consulting.
Barefoot Web-slave, antique illustrations: B http://www.fromoldbooks.org
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Creating strings with apo, Martin Honnen martin | Thread | Re: [xsl] Creating strings with apo, dvint@xxxxxxxxx |
| Re: [xsl] Creating strings with apo, David Carlisle d.p.c | Date | Re: [xsl] Creating strings with apo, Martin Honnen martin |
| Month |