有谁知道如何使用 XSLT 中的 XSpec 测试这个简单的代码?
<xsl:template match="@NameTitle">
<NameTitle Value="{if(. = ('Sir', 'Lady', 'Hon', 'R Hon')) then 'Other' else .}"
Description="{if(. = ('Sir', 'Lady', 'Hon', 'R Hon')) then . else ''}"/>
</xsl:template>
<xsl:template match="BusinessChannel/Contact/ContactPerson | SalesChannel/LoanWriter">
<PersonName>
<xsl:apply-templates select="@NameTitle"/>
<FirstName>
<xsl:value-of select="@FirstName"/>
</FirstName>
<Surname>
<xsl:value-of select="@Surname"/>
</Surname>
</PersonName>
</xsl:template>
从初学者的角度来看,使用 Xspec 测试函数很简单,但对于选择属性的模板来说则不是(至少对我来说,因为现在我已经开始使用它了)。
例如:这很容易:
<xsl:function name="fn:RemoveSpace">
<xsl:param name="RemoveSpace"/>
<xsl:if test="$RemoveSpace != ''">
<xsl:value-of select="translate($RemoveSpace, ' ', '')"/>
</xsl:if>
</xsl:function>
<x:scenario label="Scenario for testing function RemoveSpace">
<x:call function="fn:RemoveSpace">
<x:param name="RemoveSpace" select="'Person Applicant'"/>
</x:call>
<x:expect label="Remove the white space">PersonApplicant</x:expect>
</x:scenario>
欢迎任何建议。PS 我正在使用来自 OxygenXML 的 Xspec。