title: Remove the first and the last character of a string using XSLT
body: <p>I would need to transform the response from a Solr server into an XML-like formatting by using stylesheet transformations. A number of fields from the Solr schema are multivalued and include square brackets, which indicate an array. For display purposes, I would like to remove these brackets at the beginning and the end of the field value. Currently, my XSLT looks like this (the example refers to the field title and handles records with no title, too: </p>
  
  <pre><code>&lt;pnx:title&gt;
        &lt;xsl:variable name="title"&gt;
                &lt;xsl:choose&gt;
                &lt;xsl:when test="string-length(field[@name='title']) &amp;gt; 0"&gt;
                &lt;xsl:value-of select="field[@name='title']" /&gt;
                &lt;/xsl:when&gt;
                &lt;xsl:otherwise&gt;
                &lt;xsl:value-of select="field[@name='text']" /&gt;
                &lt;/xsl:otherwise&gt;
                &lt;/xsl:choose&gt;
                &lt;/xsl:variable&gt;
  
                &lt;!-- handle empty title --&gt;
                &lt;xsl:choose&gt;
                &lt;xsl:when test="string-length($title) = 0"&gt;
                Untitled
                &lt;/xsl:when&gt;
                &lt;xsl:otherwise&gt;
                &lt;xsl:value-of select="$title"/&gt;
                &lt;/xsl:otherwise&gt;
                &lt;/xsl:choose&gt;
                &lt;/pnx:title&gt;
  </code></pre>
  
  <p>I would normally use substring(string, number, number) to remove characters from a string, but in this case I do not know the position of the last character. Any idea?</p>
  
  <p>Thanks,
  I.</p>