如何减少这个记录?
<xsl:template match="BR">
<br/>
</xsl:template>
<xsl:template match="B">
<strong><xsl:apply-templates /></strong>
</xsl:template>
<xsl:template match="STRONG">
<strong><xsl:apply-templates /></strong>
</xsl:template>
<xsl:template match="I">
<em><xsl:apply-templates /></em>
</xsl:template>
<xsl:template match="EM">
<em><xsl:apply-templates /></em>
</xsl:template>
<xsl:template match="OL">
<ol><xsl:apply-templates /></ol>
</xsl:template>
<xsl:template match="UL">
<ul><xsl:apply-templates /></ul>
</xsl:template>
<xsl:template match="LI">
<li><xsl:apply-templates /></li>
</xsl:template>
<xsl:template match="SUB">
<sub><xsl:apply-templates /></sub>
</xsl:template>
<xsl:template match="SUP">
<sup><xsl:apply-templates /></sup>
</xsl:template>
<xsl:template match="NOBR">
<nobr><xsl:apply-templates /></nobr>
</xsl:template>发布于 2010-04-13 13:08:26
如果要创建的元素事先不知道,并且只需要以另一种更具体的方式处理几个已知的元素,那么这里有一个更动态的解决方案
<xsl:template match="*">
<xsl:element name="{translate(name(), $vUpper, $vLower)}">
<xsl:apply-templates select="node()|@*"/>
</xsl:element>
</xsl:template>其中$vUpper和$vLower定义为:
<xsl:variable name="vUpper" select=
"'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
"/>
<xsl:variable name="vLower" select=
"'abcdefghijklmnopqrstuvwxyz'
"/>必须有匹配少数已知元素的模板,这些元素不应该以上述方式处理。,这些更具体的模板将覆盖上面更通用的模板。例如:
<xsl:template match="specificName">
<!-- Specific processing here -->
</xsl:template>,上面的通用模板,匹配的元素应该覆盖 “身份规则” (模板)。
发布于 2010-04-13 10:14:53
也许是这样:
<xsl:template match="LI|SUB|...">
<xsl:element name="{translate(name(),
'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')}">
<xsl:apply-templates/>
</xsl:element>
</xsl:template>我不认为XSLT中有tolower函数(至少1.0中没有)
https://stackoverflow.com/questions/2628533
复制相似问题