title: XSLT transformation string to datetime format
body: <p>I'm trying to convert a date/time that is in string format to datetime format. I currently have this but it's not working:</p>
  
  <pre><code>&lt;xsl:function name="hcim:ParseDateTime" as="xs:dateTime"&gt;
      &lt;xsl:param name="DateTimeAsString" as="xs:string"/&gt;
  
      &lt;xsl:variable name="date" select="xs:date(substring($DateTimeAsString, 0, 10))"/&gt;
      &lt;xsl:variable name="time" select="xs:time(substring($DateTimeAsString, 11, 8))"/&gt;
      &lt;xsl:value-of select="dateTime($date, $time)" /&gt;
  &lt;/xsl:function&gt;
  </code></pre>
  
  <p>The error I'm getting is:</p>
  
  <pre><code>XSLT2 Transformation failed: Error in XPath 2.0 expression 
      (Cast failed, invalid lexical value - xs:date 'String' - xs:date)
  Error occurred in file '******' in statement 
      'select="xs:date(substring($DateTimeAsString, 0, 10))"'.
  </code></pre>
  
  <p>Is there a better way to do this? My incoming string is in the format:</p>
  
  <pre><code>2011-07-15 01:05:14 PM
  </code></pre>