Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This is very straightforward with an <code>xsl:choose</code> element, and doesn't require any extensions.</p> <p>This <strong>stylesheet</strong></p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"&gt; &lt;xsl:strip-space elements="*"/&gt; &lt;xsl:output method="xml" indent="yes"/&gt; &lt;xsl:template match="/root"&gt; &lt;xsl:copy&gt; &lt;xsl:apply-templates/&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;xsl:template match="date"&gt; &lt;xsl:copy&gt; &lt;xsl:call-template name="date"&gt; &lt;xsl:with-param name="dd-mmm-yyyy" select="."/&gt; &lt;/xsl:call-template&gt; &lt;/xsl:copy&gt; &lt;/xsl:template&gt; &lt;xsl:template name="date"&gt; &lt;xsl:param name="dd-mmm-yyyy"/&gt; &lt;xsl:variable name="dd" select="substring-before($dd-mmm-yyyy, '-')"/&gt; &lt;xsl:variable name="mmm-yyyy" select="substring-after($dd-mmm-yyyy, '-')"/&gt; &lt;xsl:variable name="mmm" select="substring-before($mmm-yyyy, '-')"/&gt; &lt;xsl:variable name="yyyy" select="substring-after($mmm-yyyy, '-')"/&gt; &lt;xsl:value-of select="$yyyy"/&gt; &lt;xsl:choose&gt; &lt;xsl:when test="$mmm = 'JAN'"&gt;01&lt;/xsl:when&gt; &lt;xsl:when test="$mmm = 'FEB'"&gt;02&lt;/xsl:when&gt; &lt;xsl:when test="$mmm = 'MAR'"&gt;03&lt;/xsl:when&gt; &lt;xsl:when test="$mmm = 'APR'"&gt;04&lt;/xsl:when&gt; &lt;xsl:when test="$mmm = 'MAY'"&gt;05&lt;/xsl:when&gt; &lt;xsl:when test="$mmm = 'JUN'"&gt;06&lt;/xsl:when&gt; &lt;xsl:when test="$mmm = 'JUL'"&gt;07&lt;/xsl:when&gt; &lt;xsl:when test="$mmm = 'AUG'"&gt;08&lt;/xsl:when&gt; &lt;xsl:when test="$mmm = 'SEP'"&gt;09&lt;/xsl:when&gt; &lt;xsl:when test="$mmm = 'OCT'"&gt;10&lt;/xsl:when&gt; &lt;xsl:when test="$mmm = 'NOV'"&gt;11&lt;/xsl:when&gt; &lt;xsl:when test="$mmm = 'DEC'"&gt;12&lt;/xsl:when&gt; &lt;/xsl:choose&gt; &lt;xsl:value-of select="$dd"/&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&gt; </code></pre> <p>Applied to this <strong>XML</strong> data</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;root&gt; &lt;date&gt;10-JAN-2013&lt;/date&gt; &lt;date&gt;04-JUL-1776&lt;/date&gt; &lt;date&gt;31-DEC-1999&lt;/date&gt; &lt;/root&gt; </code></pre> <p>Produces this <strong>output</strong></p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;root&gt; &lt;date&gt;20130110&lt;/date&gt; &lt;date&gt;17760704&lt;/date&gt; &lt;date&gt;19991231&lt;/date&gt; &lt;/root&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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