Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you can use <strong>node-set</strong> as extension to your xslt 1.0 processor you can try this.</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:exsl="http://exslt.org/common" extension-element-prefixes="exsl"&gt; &lt;xsl:output method="xml" indent="yes" /&gt; &lt;xsl:variable name="date" select="'10-JAN-2013'" /&gt; &lt;xsl:variable name="month_data_tmp"&gt; &lt;month short="JAN" nr="01" /&gt; &lt;!--- and so on for each month --&gt; &lt;/xsl:variable&gt; &lt;xsl:variable name="month_data" select="exsl:node-set($month_data_tmp)" /&gt; &lt;xsl:template name="format_date" &gt; &lt;xsl:param name ="date" /&gt; &lt;xsl:variable name ="day" select="substring-before($date, '-')" /&gt; &lt;xsl:variable name ="month_and_year" select="substring-after($date, '-')" /&gt; &lt;xsl:variable name ="year" select="substring-after($month_and_year, '-')" /&gt; &lt;xsl:variable name ="month" select="substring-before($month_and_year, '-')" /&gt; &lt;xsl:value-of select="$year"/&gt; &lt;xsl:value-of select="$month_data/month[@short=$month]/@nr"/&gt; &lt;xsl:value-of select="$day"/&gt; &lt;/xsl:template&gt; &lt;xsl:template match="/" &gt; &lt;xsl:call-template name="format_date" &gt; &lt;xsl:with-param name ="date" select="$date"/&gt; &lt;/xsl:call-template&gt; &lt;/xsl:template&gt; </code></pre> <p></p> <p>The output will be:</p> <pre><code>20130110 </code></pre> <p>Update doe to additional question in command:</p> <p>You can call the template at any place where you have used <code>&lt;xsl:value-of select="$date"/&gt;</code>before.</p> <pre><code>&lt;result&gt; &lt;xsl:call-template name="format_date" &gt; &lt;xsl:with-param name ="date" select="$date"/&gt; &lt;/xsl:call-template&gt; &lt;/result&gt; </code></pre> <p>Or you can assign the result to an new variable and use this.</p> <pre><code>&lt;xsl:variable name="newdate"&gt; &lt;xsl:call-template name="format_date" &gt; &lt;xsl:with-param name ="date" select="$date"/&gt; &lt;/xsl:call-template&gt; &lt;/xsl:variable&gt; &lt;result&gt; &lt;xsl:value-of select="$newdate"/&gt; &lt;/result&gt; </code></pre>
    singulars
    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. 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.
 

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