この問題は、今日私を夢中にさせています。
(以下の文字のエンコードを停止するためにスペースを追加したことに注意してください)
入力 XML ファイルには、"& lt;li class=& quot;classname& quot;& gt;" のような html テキストがあります。
入力ファイルは、必要に応じて正しくエンコードされています。
問題は、XML を CSV に変換するために XSLT を使用して実行していることです。& lt; はすべて問題ありませんでした。& gt; ですが、XSLT は & quot; を出力しています。'"' として。
xslt で引用符を & quot; に置き換える方法がわかりませんでした。そのため、xslt 処理には既に ant を使用しているため、'\" を置き換えるには ANT replace を使用する方が簡単だと思いました。 ' xslt タスクの後に & quot; を付けます。
今、私は狂っています。なぜなら、ANTも拡大しているからです & quot; \" を "!!! に置き換えます。
質問の一部: 1. & quot; を保存する方法はありますか? xslt 変換中。(最善) 2. そうでない場合、" を xslt の & quot; に文字列置換する方法はありますか?実在物)
蟻
<replace file="${dataload.dataDir}/inbound/products/wc_store_locator.csv" token='\"' value=""" />
XSLT
<xsl:call-template name="replace-quotes">
<xsl:with-param name="text" select="notificationMessage"/>
<xsl:with-param name="replace" select="'"'" />
<xsl:with-param name="with" select="'\"'"/>
</xsl:call-template>
<xsl:text>"</xsl:text>
<xsl:text> </xsl:text>
</xsl:for-each>
</xsl:template>
<xsl:template name="replace-quotes">
<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-quotes">
<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>