0

xslt 1.0 を使用して xml を変換しています。

私はこの文字列を持っています:

hello 1s: This is very nice day. 9s: Christmas is about to come 14s: and christmas preparation is just on 25s: this is awesome!! 

次のようにフォーマットしたい:

hello This is very nice day. Christmas is about to come and christmas preparation is just on this is awesome!! 

これを行うために、次の xslt を試しました。

<?xml version='1.0' encoding='UTF-8' ?>
<xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:regexp="http://exslt.org/regular-expressions"
                extension-element-prefixes="regexp"  >
<xsl:import href="regexp.xsl" />
  <xsl:template match='/'>
         <xsl:value-of select="regexp:replace(string(.), '[0-9]{1,4}s: ', 'g', '')" />
  </xsl:template>
</xsl:stylesheet>

しかし、それを実行すると次のエラーが発生します。

java.lang.NoSuchMethodException: For extension function, could not find method java.lang.String.replace([ExpressionContext,] #STRING, #STRING, #STRING).

私は何を間違っていますか?

4

2 に答える 2

1

XSLT 1.0 には、正規表現の組み込みサポートはありません。呼び出している EXSLT 関数は、一部のプロセッサで使用できる拡張関数のサードパーティ仕様です。表示されるエラー メッセージは、特定のプロセッサでは使用できないことを示しています (または、そのプロセッサ用に何らかの方法でインストール/構成する必要があることを示しています)。

Java を使用しているので、XSLT 2.0 を Saxon の形式で使用しても問題はありません。

于 2011-12-30T18:51:01.057 に答える