1

パディング、IE の先頭および/または末尾の空白を削除する簡単な方法はありますか。EXSLT パディング関数は、特定の長さにパディングまたはトリム文字列のみを作成するようです。

4

3 に答える 3

2

正規化スペースを試す

<xsl:value-of select='normalize-space(string)'/>
于 2010-09-08T13:27:57.110 に答える
1

normalize-space() はあなたのために仕事をしますか? これにより、文字列内のスペースも削減されます。

"  this         string    " 

次のようになります。

"this string"

「トリム」関数が本当に必要な場合は、おそらくnormalizse-space() で既に実装している他の誰かから盗むことができます...

于 2010-09-08T13:27:05.303 に答える
0

何が必要なのかは明確ではありません -- 「ストリップパディング」とは何ですか?

trim() 関数を意味する場合は、

FXSLライブラリは、便利trimなテンプレート機能を提供します。

この変換:

<xsl:stylesheet version="1.0" 
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

  <xsl:import href="trim.xsl"/>

  <xsl:output method="text"/>
  <xsl:template match="/">
    '<xsl:call-template name="trim">
        <xsl:with-param name="pStr" select="string(/*)"/>
    </xsl:call-template>'
  </xsl:template>
</xsl:stylesheet>

この XML ドキュメントに適用した場合:

<someText>

   This is    some text   

</someText>

必要な正しい結果が生成されます

'This is    some text'
于 2010-09-08T13:43:25.007 に答える