Note that there are some explanatory texts on larger screens.

plurals
  1. POSubstring value Processing in recursion
    primarykey
    data
    text
    <p>This is all about reverse a string. It works properly for the given Value 'ABCDEF'. The output is also correct 'FEDCBA'. But I want to know how this is printing letters 'A' and 'D' in this string. Could anyone help me to understand this? please. Elaborate this working method.</p> <pre><code>&lt;xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs"&gt; &lt;xsl:output method="html"/&gt; &lt;xsl:template name="reverse"&gt; &lt;xsl:param name="input" select="'ABCDEF'"/&gt; &lt;xsl:variable name="len" select="string-length($input)"/&gt; &lt;xsl:choose&gt; &lt;xsl:when test="$len &amp;lt; 2"&gt; &lt;xsl:value-of select="$input"/&gt; &lt;/xsl:when&gt; &lt;xsl:when test="$len = 2"&gt; &lt;xsl:value-of select="substring($input,2,1)"/&gt; &lt;xsl:value-of select="substring($input,1,1)"/&gt; &lt;/xsl:when&gt; &lt;xsl:otherwise&gt; &lt;xsl:variable name="mid" select="floor($len div 2)"/&gt; &lt;xsl:call-template name="reverse"&gt; &lt;xsl:with-param name="input" select="substring($input,$mid+1,$mid+1)"/&gt; &lt;/xsl:call-template&gt; &lt;xsl:call-template name="reverse"&gt; &lt;xsl:with-param name="input" select="substring($input,1,$mid)"/&gt; &lt;/xsl:call-template&gt; &lt;/xsl:otherwise&gt; &lt;/xsl:choose&gt; &lt;/xsl:template&gt; &lt;xsl:template match="/"&gt; &lt;xsl:call-template name="reverse"&gt; &lt;/xsl:call-template&gt; &lt;/xsl:template&gt; &lt;/xsl:stylesheet&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. 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