Class 将类应用于通过测试找到的元素
我还不熟悉XSLT 如何将类应用于使用xsl:if找到的元素 XML:Class 将类应用于通过测试找到的元素,class,xslt,Class,Xslt,我还不熟悉XSLT 如何将类应用于使用xsl:if找到的元素 XML: 一些文本 我想要的输出: <h3 class="box-list-link">Some Text </h3> 一些文本 我有这样的东西: <xsl:for-each select ="./ColumnBody" > <xsl:call-template name="RichText"></xsl:call-template> </xsl:for
一些文本
我想要的输出:
<h3 class="box-list-link">Some Text </h3>
一些文本
我有这样的东西:
<xsl:for-each select ="./ColumnBody" >
<xsl:call-template name="RichText"></xsl:call-template>
</xsl:for-each>
<xsl:template name="RichText">
<p>
<xsl:copy-of select="./node()" />
</p>
</xsl:template>
您喜欢这项工作吗
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="h3">
<h3 class="box-list-link">
<xsl:apply-templates/>
</h3>
</xsl:template>
</xsl:stylesheet>
如果我们能看到输入XML和预期的输出,这个问题就会清楚得多。
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:strip-space elements="*"/>
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="h3">
<h3 class="box-list-link">
<xsl:apply-templates/>
</h3>
</xsl:template>
</xsl:stylesheet>