|
Subject: Re: [xsl] Replace(//text()) in XSLT 1 From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Fri, 16 Nov 2012 12:05:48 -0500 |
I'd like to replace hyphens with en dashes. In XSLT 2.0, I can do this with replace(text()), but I'm limited to XSLT 1.0.
How could I achieve the same thing in XSLT 1.0?
<xsl:value-of select="replace(//text(), '-', '–')"/>
<xsl:template name="dashes">
<xsl:param name="content" select="."/>
<xsl:choose>
<xsl:when test="contains($content,'-')">
<xsl:value-of select="substring-before($content,'-')"/>
<xsl:text>–</xsl:text>
<xsl:call-template name="dashes">
<xsl:with-param name="content"
select="substring-after($content,'-')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$content"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>-- Contact us for world-wide XML consulting and instructor-led training Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Google+ profile: https://plus.google.com/116832879756988317389/about Legal business disclaimers: http://www.CraneSoftwrights.com/legal
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] Replace(//text()) in XSLT 1, Nathan Tallman | Thread | Re: [xsl] Replace(//text()) in XSLT, Martin Honnen |
| [xsl] Replace(//text()) in XSLT 1, Nathan Tallman | Date | Re: [xsl] Replace(//text()) in XSLT, Martin Honnen |
| Month |