|
Subject: Re: [xsl] How to substitute a portion of the text value of an element From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx> Date: Tue, 07 Oct 2008 14:53:18 -0400 |
I've got an element like this:
<box:base-file-name>C:/test10/user/server/logs/server.log</box:base-file-name>
I'd like it to look like this:
<box:base-file-name>C:/other103/user/server/logs/server.log</box:base-file-name>
I'm passing in an OLD parameter that contains "c:/test10" and a NEW parameter that contains "c:/other103" but I'm not sure how to substitute just the OLD portion for the NEW parameter in the value of box:base-file-name without nuking the rest of the value which I want to preserve.
Is it possible to just change a portion of the value?
T:\ftemp>type paul.xsl <?xml version="1.0" encoding="US-ASCII"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsd="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xsd" version="2.0">
<xsl:template match="/">
<result>
<xslt20>
<xsl:apply-templates select="*" mode="x2">
<xsl:with-param name="old">C:/test10</xsl:with-param>
<xsl:with-param name="new">C:/other103</xsl:with-param>
</xsl:apply-templates>
</xslt20>
<xslt10>
<xsl:apply-templates select="*" mode="x1">
<xsl:with-param name="old">C:/test10</xsl:with-param>
<xsl:with-param name="new">C:/other103</xsl:with-param>
</xsl:apply-templates>
</xslt10>
</result>
</xsl:template><xsl:template match="*" mode="x1">
<xsl:param name="old"/>
<xsl:param name="new"/>
<xsl:copy>
<xsl:value-of select="substring-before(.,$old)"/>
<xsl:value-of select="$new"/>
<xsl:value-of select="substring-after(.,$old)"/>
</xsl:copy>
</xsl:template>-- Upcoming XSLT/XSL-FO hands-on courses: Wellington, NZ 2009-01 Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video sample lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg Video course overview: http://www.youtube.com/watch?v=VTiodiij6gE G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] How to substitute a portion o, Paul | Thread | Re: [xsl] How to substitute a porti, Paul |
| [xsl] How to substitute a portion o, Paul | Date | Re: [xsl] How to substitute a porti, Paul |
| Month |