转换Xsl时如何确定节点是否存在?

uda*_*726 1 xml xslt

如何确定输入xml中是否存在给定节点?

如果节点存在,我想使用值reportAuthor1,但否则我会使用值reportAuthor.我尝试使用if和else失败了.

 <xsl:choose>
 <xsl:when test="reportAuthor1=''">
 <xsl:value-of select="reportAuthor"/>
 </xsl:when>
 <xsl:otherwise>
 <xsl:value-of select="reportAuthor1"/>
 </xsl:otherwise>
 </xsl:choose>
Run Code Online (Sandbox Code Playgroud)

Stu*_*tLC 5

使用not()检查节点是否不存在于所有:

<xsl:choose>  
  <xsl:when test="not(reportAuthor1)">  
    <xsl:value-of select="reportAuthor"/>
  </xsl:when>  
  <xsl:otherwise>  
    <xsl:value-of select="reportAuthor1"/>  
  </xsl:otherwise>  
</xsl:choose> 
Run Code Online (Sandbox Code Playgroud)