Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There aren't any regular expressions in XSLT 1.0, so I'm afraid that pattern matching isn't going to be possible.</p> <p>I'm not clear if <code>&lt;srcTime&gt;23:00&lt;/srcTime&gt;</code> is supposed to be legal or not? If it is, try:</p> <pre><code>&lt;dstTime&gt; &lt;xsl:if test="string-length(srcTime) = 4 or string-length(srcTime) = 5"&gt; &lt;xsl:variable name="hour" select="substring(srcTime, 1, 2)" /&gt; &lt;xsl:if test="$hour &gt;= 0 and 24 &gt; $hour"&gt; &lt;xsl:variable name="minute"&gt; &lt;xsl:choose&gt; &lt;xsl:when test="string-length(srcTime) = 5 and substring(srcTime, 3, 1) = ':'"&gt; &lt;xsl:value-of select="substring(srcTime, 4, 2)" /&gt; &lt;/xsl:when&gt; &lt;xsl:when test="string-length(srcTime) = 4"&gt; &lt;xsl:value-of select="substring(srcTime, 3, 2)" /&gt; &lt;/xsl:when&gt; &lt;/xsl:choose&gt; &lt;/xsl:variable&gt; &lt;xsl:if test="$minute &gt;= 0 and 60 &gt; $minute"&gt; &lt;xsl:value-of select="concat($hour, ':', $minute)" /&gt; &lt;/xsl:if&gt; &lt;/xsl:if&gt; &lt;/xsl:if&gt; &lt;/dstTime&gt; </code></pre> <p>If it isn't, and four digits is the only thing that's legal then:</p> <pre><code>&lt;dstTime&gt; &lt;xsl:if test="string-length(srcTime) = 4"&gt; &lt;xsl:variable name="hour" select="substring(srcTime, 1, 2)" /&gt; &lt;xsl:if test="$hour &gt;= 0 and 24 &gt; $hour"&gt; &lt;xsl:variable name="minute" select="substring(srcTime, 3, 2)" /&gt; &lt;xsl:if test="$minute &gt;= 0 and 60 &gt; $minute"&gt; &lt;xsl:value-of select="concat($hour, ':', $minute)" /&gt; &lt;/xsl:if&gt; &lt;/xsl:if&gt; &lt;/xsl:if&gt; &lt;/dstTime&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