这是可能的。在XSLT 2.0中,这将是一个轻而易举(具有正则表达式)。然而,这是直接的“你说什么”脚本在XSLT 1.0:
<xsl:template match="/">
<xsl:call-template name="process">
<xsl:with-param name="text" select="/tutorial/MT/@V"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="process">
<xsl:param name="text" select="."/>
<xsl:variable name="modtext" select="translate($text,'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ','aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa')"/>
<xsl:variable name="pretext" select="substring-before($modtext,'<a')"/>
<xsl:choose>
<xsl:when test="not($pretext)">
<xsl:value-of select="$text"/>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="endpos" select="string-length($pretext)+1"/>
<xsl:value-of select="concat(substring($text,1, $endpos),' ')"/>
<xsl:call-template name="process">
<xsl:with-param name="text"
select="substring($text,$endpos+1)"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
产生你问什么,但它的表现很奇怪数字和/字符。
它产生:
Centre-of-mass energies in the region 142< W< sub>γp</sub><293 GeV with the ZEUS detector at HERA using an integrated luminosity
显然,如果你更新与翻译/和1234567890它会处理数字和斜线了。
谢谢!它按需要工作。 *我想我的需求非常安全。 – itsbalur 2012-07-18 08:59:33
'*'有时可能是安全的,但为什么要培养一个bug。固定。 – 2012-07-18 09:09:37