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:
<pnx:title>
<xsl:variable name="title">
<xsl:choose>
<xsl:when test="string-length(field[@name='title']) > 0">
<xsl:value-of select="field[@name='title']" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="field[@name='text']" />
</xsl:otherwise>
</xsl:choose>
</xsl:variable>
<!-- handle empty title -->
<xsl:choose>
<xsl:when test="string-length($title) = 0">
Untitled
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$title"/>
</xsl:otherwise>
</xsl:choose>
</pnx:title>
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?
Thanks, I.