我会检查文档是否包含给定的值和 xpath,如果它确实使用了选定的值,则使用另一个值。我在 XSLT 方面真的很糟糕,但这是我开始的:
<xsl:choose>
<xsl:when test="p//section.std[@type = 'SpecialSection']/p/img/@alt">
<xsl:apply-templates select="p//section.std[@type = 'SpecialSection']/p/img/@alt"/>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="p//meta-data.titles/meta-data.title"/>
</xsl:otherwise>
</xsl:choose>
当前未选择任何值。我怀疑我不能像以前那样编写我的选择测试。我不确定空值是否计算为布尔值。基本上我想测试第一个 xpath 是否返回一个值以及它是否使用它,如果不使用块中的那个。
有什么帮助吗?