xsl-list
[Top] [All Lists]

Re: [xsl] Placing mark-up in between strings

2006-11-23 08:02:06

Are you sure these are the only characters to escape? 

They are all the ones that can be escaped with \
see
http://www.w3.org/TR/xmlschema-2/#dt-cces1

which includes - so I put it in although you don't need to escape it
really as it's only special in [a-z] and if you have already escaped [
and ] then - will never be taken to be a character range.

And '$'?

which reminds me I didn't include the special characters added in xpath
regex, so yes you need to add $ (but that's the only one)

http://www.w3.org/TR/xpath-functions/#regex-syntax

so corrected function is

 <xsl:function name="f:escape">
   <xsl:param name="s" as="xs:string"/>
   <xsl:sequence 
select="replace($s,'[\\\|\.\-\^\?\*\+\(\)\{\}\[\]\$]','\\$0')"/>
 </xsl:function>

David

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--