translate(string,':',', ')
しかし、これは "aa ,, bb ,, aa"を返す
どのようにこれを行うことができます。
translate(string,':',', ')
しかし、これは "aa ,, bb ,, aa"を返す
どのようにこれを行うことができます。
非常に簡単な解決策(つまり、限り、あなたの文字列値にスペースを持っていないと動作します):
translate(normalize-space(translate('aa::bb::cc',':',' ')),' ',',')
normalize-space()
" 複数の崩れ空白文字を1つの空白に変換する」より堅牢なソリューションをrecursive templateを使用することです:
<xsl:template name="replace-string">
<xsl:param name="text"/>
<xsl:param name="replace"/>
<xsl:param name="with"/>
<xsl:choose>
<xsl:when test="contains($text,$replace)">
<xsl:value-of select="substring-before($text,$replace)"/>
<xsl:value-of select="$with"/>
<xsl:call-template name="replace-string">
<xsl:with-param name="text"
select="substring-after($text,$replace)"/>
<xsl:with-param name="replace" select="$replace"/>
<xsl:with-param name="with" select="$with"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
あなたはこのようにそれを使用することができます:
<xsl:call-template name="replace-string">
<xsl:with-param name="text" select="'aa::bb::cc'"/>
<xsl:with-param name="replace" select="'::'" />
<xsl:with-param name="with" select="','"/>
</xsl:call-template>
あなたはこの
文法を使用することができます: - fn:tokenize(string,pattern)
を
Exa mple:tokenize("XPath is fun", "\s+")
結果:( "XPath"、 "is"、 "fun")
この質問はXSLT 1.0とタグ付けされています。あなたの答えにはXSLT 2.0が必要です。 –