[xsl] string replace with ­

Subject: [xsl] string replace with ­
From: "Miller, James V (CRD)" <millerjv@xxxxxxxxxx>
Date: Fri, 2 Nov 2001 10:42:49 -0500
I have an XML file that I am converting to HTML. In the processing, I have a string of the form
"machine.site.domain".  These strings can be fairly long.  When I output the HTML, I would to add a
hint to the browser that it can hyphenate this string at any ".".  So when I output the string I
would like it to be


So that it can be rendered as 




as needed.

I've several versions of a recursive template to replace all occurences of "." with "&shy;.".
my output string always end up being


which renders as


I am using the xalan XSLT engine.

I has a working version of this that only replaced the first "." with &shy; that worked fine.  But
that was being done inline and not in a recursive template.

<xsl:template name="SoftHyphenString">
    <xsl:param name="src"/>
    <xsl:param name="dst"/>

       <xsl:when test="string-length($src) = 0">
          <xsl:value-of select="$dst"/>
          <xsl:call-template name="SoftHyphenString">
             <xsl:with-param name="src">
                 <xsl:value-of select="substring-after($src, '.')"/>
             <xsl:with-param name="dst">
                  <xsl:when test="contains($src, '.')">
                      <xsl:value-of select="concat($dst, substring-before($src, '.'))"/><xsl:text
                     <xsl:value-of select="concat($dst, $src)"/>

Jim Miller 
Visualization & Computer Vision
GE Corporate Research & Development
Bldg. KW, Room C218B
P.O. Box 8, Schenectady NY 12301

millerjv@xxxxxxxxxx <mailto:millerjv@xxxxxxxxxx>
(518) 387-4005, Dial Comm: 8*833-4005, 
Cell: (518) 505-7065, Fax: (518) 387-6981 

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread