<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Alessandro Melandri &#187; XSL</title>
	<atom:link href="http://www.melandri.net/tag/xsl/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.melandri.net</link>
	<description>J2EE Developer &#38; Photography enthusiast</description>
	<lastBuildDate>Tue, 27 Jul 2010 19:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Remove leading zeroes in XSL</title>
		<link>http://www.melandri.net/2009/06/22/remove-leading-zeroes-in-xsl/</link>
		<comments>http://www.melandri.net/2009/06/22/remove-leading-zeroes-in-xsl/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 11:09:55 +0000</pubDate>
		<dc:creator>amelandri</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[XSL]]></category>
		<category><![CDATA[XSL template]]></category>

		<guid isPermaLink="false">http://www.melandri.net/?p=103</guid>
		<description><![CDATA[A useful XSL template for removing leading zeros &#60;xsl:template name=&#34;removeLeadingZeros&#34;&#62; &#60;xsl:param name=&#34;originalString&#34;/&#62; &#60;xsl:choose&#62; &#60;xsl:when test=&#34;starts-with($originalString,'0')&#34;&#62; &#60;xsl:call-template name=&#34;removeLeadingZeros&#34;&#62; &#60;xsl:with-param name=&#34;originalString&#34;&#62; &#60;xsl:value-of select=&#34;substring-after($originalString,'0' )&#34;/&#62; &#60;/xsl:with-param&#62; &#60;/xsl:call-template&#62; &#60;/xsl:when&#62; &#60;xsl:otherwise&#62; &#60;xsl:value-of select=&#34;$originalString&#34;/&#62; &#60;/xsl:otherwise&#62; &#60;/xsl:choose&#62; &#60;/xsl:template&#62; Just insert it into your XSL file and use it as usual: &#60;xsl:call-template name=&#34;removeLeadingZeros&#34;&#62; &#60;xsl:with-param name=&#34;originalString&#34; select=&#34;$myOriginalString&#34;/&#62; &#60;/xsl:call-template&#62;]]></description>
			<content:encoded><![CDATA[<p>A useful XSL template for removing leading zeros</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:template</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;removeLeadingZeros&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>  
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;originalString&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>  
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:choose<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>  
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:when</span> <span style="color: #000066;">test</span>=<span style="color: #ff0000;">&quot;starts-with($originalString,'0')&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>  
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:call-template</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;removeLeadingZeros&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>  
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:with-param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;originalString&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>  
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;substring-after($originalString,'0' )&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>  
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:with-param<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>  
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:call-template<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>  
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:when<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>  
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:otherwise<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>  
      <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:value-of</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;$originalString&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>  
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:otherwise<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>  
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:choose<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>  
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:template<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Just insert it into your XSL file and use it as usual:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:call-template</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;removeLeadingZeros&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>  
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;xsl:with-param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;originalString&quot;</span> <span style="color: #000066;">select</span>=<span style="color: #ff0000;">&quot;$myOriginalString&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>  
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/xsl:call-template<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.melandri.net/2009/06/22/remove-leading-zeroes-in-xsl/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
