我正在通过XSLT使用XML数据创建幻灯片。部分过程是使用标题初始化数组:
item[0] = ["How do I jump?"];
item[1] = ["I know how to jump!"];
item[2] = ["Did you read "how to jump""];
请注意,第3个元素的书名是双引号?好吧,初始化该元素会导致样式表的编译出现问题(应该如此),但有没有办法去除双引号并用单引号替换它们?
<xsl:variable name="apos"><xsl:text>'</xsl:text></xsl:variable>
<xsl:variable name="double_quote"><xsl:text>"</xsl:text></xsl:variable>
<xsl:for-each select="/data/calendar/event/title">
<xsl:variable name="index">
<xsl:value-of select="position() - 1"/>
</xsl:variable>
<xsl:variable name="safeTitle" select="translate(text(),$double_quote, $apos)" /><!-- prevents double quotes from being used inside an array using double quotes -->
fadetitlesSS12<xsl:value-of select="/data/calendar/id" />[<xsl:value-of select="$index" />]=["<xsl:value-of select="$safeTitle" />"];
</xsl:for-each>