troubleshooting Question

xslt 1.0 - Formatting string (Substrings from the End of a String)

Avatar of Darius
DariusFlag for Lithuania asked on
3 Comments1 Solution206 ViewsLast Modified:
Hi guys,

Please assist with this validation.
Have an issue to substring from the End of a String.
Please see below

           <xsl:variable name="originalValue" select="'[some Values]'" />

                <xsl:variable name="valueUpdated">
                  <xsl:call-template name="cut-leading-zeros">
                    <xsl:with-param name="str" select="normalize-space($originalValue)" />

                <!-- If original values does not have leading zeros
                 . . .
                  concat orginal value with prefix 'BX' 
                <xsl:if test="$originalValue">
                  <xsl:value-of select="concat('BX', $originalValue)"/>

                <!-- If updated values after removed leading zeros greather then 18
                  . . .
                  concat updated value with prefix 'BX' 
                <xsl:if test="string-length($valueUpdated) &gt; 18">
                  <xsl:value-of select="concat('BX', $valueUpdated)"/>

                <!-- If original values after removed leading zeros less then 18
                  . . .
                  substring from the End of a String to 18 digits
                  and concat value with prefix 'BX' 
                  expect values:
                <xsl:if test="string-length($valueUpdated) &lt; 18">
                  <!--max length 20:  'BX' and value-->
                  . . . to do . . .


  <xsl:template name="cut-leading-zeros">
    <xsl:param name="str"/>
      <xsl:when test="substring($str, 1, 1) = '0'">
        <xsl:call-template name="cut-leading-zeros">
          <xsl:with-param name="str" select="substring($str, 2)"/>
        <xsl:value-of select="$str"/>

Thank you
Gertone (Geert Bormans)
Information Architect

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Top Expert 2006

The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros