在我的 Sharepointfldtypes_custom.xsl
文件中,我有这段代码,它运行良好。但是,我想在三个或四个类似的字段上使用相同的代码。
有没有办法在同一个模板中匹配名为status1
OR status2
、 OR的字段?status3
现在我必须拥有这段代码的三个副本,唯一的区别是fieldref
名称。我想整理一下代码。
<xsl:template match="FieldRef[@Name='status1']" mode="body">
<xsl:param name="thisNode" select="."/>
<xsl:variable name="currentValue" select="$thisNode/@status1" />
<xsl:variable name="statusRating1">(1)</xsl:variable>
<xsl:variable name="statusRating2">(2)</xsl:variable>
<xsl:variable name="statusRating3">(3)</xsl:variable>
<xsl:choose>
<xsl:when test="contains($currentValue, $statusRating1)">
<span class="statusRatingX statusRating1"></span>
</xsl:when>
<xsl:when test="contains($currentValue, $statusRating2)">
<span class="statusRatingX statusRating2"></span>
</xsl:when>
<xsl:when test="contains($currentValue, $statusRating3)">
<span class="statusRatingX statusRating3"></span>
</xsl:when>
<xsl:otherwise>
<span class="statusRatingN"></span>
</xsl:otherwise>
</xsl:choose>
</xsl:template>