Avatar of badtz7229
badtz7229
Flag for United States of America asked on

XSLT: how to rebuild a string separated by a delimiter

I have the following string R/0R4/TEST/TEST AVAILABLE/R/12345678901234C1
I want to remove 1 digit from the string after the last "/" such that 1234567890123C1
I then want to rebuild the original string with the newValue such that: R/0R4/TEST/TEST AVAILABLE/R/1234567890123C1

I have the following below which shortens the last string by 1 digit. But I do not know how to rebuild it now.
<xsl:variable name="Num14">
  <xsl:call-template name="substring-after-last">
	<xsl:with-param name="input" select="$elem/Text" />
	<xsl:with-param name="marker" select="'/'" />
  </xsl:call-template>
</xsl:variable>

<xsl:variable name="Cpn" select="substring ( $Num14, 15, 2)"/>
<xsl:variable name="Num13" select="concat ( substring ( $Num14, 1, 13), $Cpn) "/>

  <xsl:template name="substring-after-last">
    <xsl:param name="input" select="''" />
    <xsl:param name="marker" select="''" />
      <xsl:choose>
        <xsl:when test="contains($input,$marker)">
          <xsl:call-template name="substring-after-last">
            <xsl:with-param name="input" select="substring-after($input,$marker)" />
            <xsl:with-param name="marker" select="$marker" />
          </xsl:call-template>
        </xsl:when>
        <xsl:otherwise>
          <xsl:value-of select="$input" />
        </xsl:otherwise>
      </xsl:choose>
  </xsl:template>

Open in new window

CSSXML

Avatar of undefined
Last Comment
badtz7229

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Gertone (Geert Bormans)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Gertone (Geert Bormans)

simply put back what you have just taken away
only do the processing on the last component before you put it back
badtz7229

ASKER
thank you. that worked.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy