title: To Substring in xsl
body: <p>Hi I am converting one XML to another XML using XSL.</p>
  
  <p>The problem I face is the value inside the tag is <code>10feb2011</code> 
  i.e <code>&lt;date&gt;10feb2011&lt;/date&gt;</code>. </p>
  
  <p>I need the output to be: </p>
  
  <pre><code> &lt;date&gt;10&lt;/date&gt;
   &lt;month&gt;feb&lt;/month&gt;
   &lt;year&gt;2011&lt;/year&gt; 
  </code></pre>
  
  <p>so I used <code>substring</code> function, but could not get it to work. </p>
  
  <p>My XML looks like</p>
  
  <pre><code>&lt;ArrivalDateTime&gt;
    &lt;Date&gt;20feb2011&lt;Date&gt;
  &lt;/ArrivalDateTime&gt;
  </code></pre>
  
  <p>It should be converted into this format</p>
  
  <pre><code> &lt;ArrivalDateTime&gt;
     &lt;dayOfMonth&gt;10&lt;/dayOfMonth&gt; 
     &lt;month&gt;feb&lt;/month&gt; 
     &lt;year&gt;2011&lt;/year&gt; 
   &lt;/ArrivalDateTime&gt;
  </code></pre>
  
  <p>Below is the XSL  I wrote </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  &lt;!-- Edited by XMLSpy® --&gt;
  &lt;xsl:stylesheet version="1.0"
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  &lt;xsl:output method="xml" indent="yes"/&gt;
  &lt;xsl:template match="/"&gt;        
  &lt;xsl:text&gt;&lt;![CDATA[&lt;ArrivalDateTime&gt;]]&gt;&lt;/xsl:text&gt;          
  &lt;xsl:text&gt;&lt;![CDATA[&lt;dayOfMonth&gt;]]&gt;&lt;/xsl:text&gt;
  &lt;xsl:value-of select='substring("&lt;xsl:value-of select="/ArrivalDateTime/Date"/&gt;",1,2)'/&gt;
  &lt;xsl:text&gt;&lt;![CDATA[&lt;/dayOfMonth&gt;]]&gt;&lt;/xsl:text&gt;
  &lt;xsl:text&gt;&lt;![CDATA[&lt;month&gt;]]&gt;&lt;/xsl:text&gt;
  &lt;xsl:value-of select='substring("&lt;xsl:value-of select="/ArrivalDateTime/Date"/&gt;",3,3)'/&gt;
  &lt;xsl:text&gt;&lt;![CDATA[&lt;/month&gt;]]&gt;&lt;/xsl:text&gt;
  &lt;xsl:text&gt;&lt;![CDATA[&lt;year&gt;]]&gt;&lt;/xsl:text&gt;
  &lt;xsl:value-of select='substring("&lt;xsl:value-of select="/ArrivalDateTime/Date"/&gt;",5,4)'/&gt;
  &lt;xsl:text&gt;&lt;![CDATA[&lt;/year&gt;]]&gt;&lt;/xsl:text&gt;
  &lt;xsl:text&gt;&lt;![CDATA[&lt;/ArrivalDateTime&gt;]]&gt;&lt;/xsl:text&gt;&lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>