ある組織 (例: www.old.com) が所有していたサイトを管理しており、現在は新しい組織 (例: www.new.com) に置き換えられています。私の問題は、サイトで使用している一部の画像の一部のリンクがまだ古い組織を指していることです. xsl を使用してhttp://www.old.comをhttp://www.new.comに置き換える方法があるかどうか疑問に思っていました。
私の考えはこれをやっていましたが、うまくいくかどうかはわかりません..
<xsl:template match="image">
<xsl:param name ="old" value='http://www.old.com'/>
<xsl:param name ="new" value='http://www.new.com'/>
<xsl:choose>
<xsl:when test="contains(@xlink:href,$old)">
<xsl:attribute name="xlink:href">
<xsl:value-of select="replace(@xlink:href, $old, $new)">
</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="xlink:href">
<xsl:value-of select="@xlink:href"/>
</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
xml は次のようになります。
<book title="Harry Potter">
<description
xlink:type="simple"
xlink:href="http://www.old.com/images/HPotter.gif"
xlink:show="new">
As his fifth year at Hogwarts School of Witchcraft and
Wizardry approaches, 15-year-old Harry Potter is.......
</description>
</book>
ご協力いただきありがとうございます