Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>Here is a general XSLT solution which would be useful also in converting a string containing a date in the format specified in the problem, into an XML-structured date:</strong> </p> <p>This uses the FXSL 1.x template <code>str-split-to-words</code> to perform tokenization with more than one possible delimiters.</p> <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ext="http://exslt.org/common"&gt; &lt;xsl:import href="strSplit-to-Words.xsl"/&gt; &lt;xsl:output indent="yes" omit-xml-declaration="yes"/&gt; &lt;xsl:template match="/"&gt; &lt;xsl:variable name="vwordNodes"&gt; &lt;xsl:call-template name="str-split-to-words"&gt; &lt;xsl:with-param name="pStr" select="/"/&gt; &lt;xsl:with-param name="pDelimiters" select="' ,'"/&gt; &lt;/xsl:call-template&gt; &lt;/xsl:variable&gt; &lt;xsl:variable name="vTokens" select="ext:node-set($vwordNodes)/*"/&gt; &lt;xsl:variable name="vrtfDateTimeStruct"&gt; &lt;date&gt; &lt;week-day-name val="{$vTokens[1]}"/&gt; &lt;day val="{$vTokens[2]}"/&gt; &lt;month-name val="{$vTokens[3]}"/&gt; &lt;year val="{$vTokens[4]}"/&gt; &lt;time val="{$vTokens[5]}"/&gt; &lt;zone val="{$vTokens[6]}"/&gt; &lt;/date&gt; &lt;/xsl:variable&gt; &lt;xsl:value-of select= "substring(ext:node-set($vrtfDateTimeStruct)/*/time/@val,1,5)"/&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p><strong>When this transformation is applied on the provided XML document</strong>:</p> <pre><code>&lt;Date&gt;Mon, 11 Aug 2009 13:15:10 GMT&lt;/Date&gt; </code></pre> <p><strong>the wanted result is produced</strong>:</p> <pre><code>13:15 </code></pre> <p><strong>Do note</strong>: The string is converted completely into an XML-structured date using this code fragment:</p> <pre><code> &lt;xsl:variable name="vrtfDateTimeStruct"&gt; &lt;date&gt; &lt;week-day-name val="{$vTokens[1]}"/&gt; &lt;day val="{$vTokens[2]}"/&gt; &lt;month-name val="{$vTokens[3]}"/&gt; &lt;year val="{$vTokens[4]}"/&gt; &lt;time val="{$vTokens[5]}"/&gt; &lt;zone val="{$vTokens[6]}"/&gt; &lt;/date&gt; &lt;/xsl:variable&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload