スタイルシート変換を使用して、Solr サーバーからの応答を XML のような形式に変換する必要があります。Solr スキーマの多くのフィールドは多値であり、配列を示す角括弧が含まれています。表示のために、フィールド値の最初と最後にあるこれらのブラケットを削除したいと思います。現在、私の XSLT は次のようになっています (この例では、フィールド タイトルを参照し、タイトルのないレコードも処理しています。
<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>
通常、文字列から文字を削除するには substring(string, number, number) を使用しますが、この場合、最後の文字の位置がわかりません。何か案が?
ありがとう、私。