使用XSLT检测属性值何时才应使用?

3
我在我的代码中使用了<xsl:when>,我需要测试下面的"when"条件中的2个不同属性的值,即(<xsl:when test="??">)。请问如何实现?
我尝试了这个方法,但它并不起作用:
<xsl:when test="@Attrb1[.!=''] and @Attrb2[.!='']">

另外,这也会出现错误:

<xsl:when test="@Attrb1 !='' and @Attrb2 !=''"> 

msxml3.dll错误 '80004005'

错误 '80004005'
预期的令牌是'eof',却发现'!='。@Attrb -->!=<--'' and @Attrb2 !=''

代码:

<xsl:when test="Condition1"> 
<xsl:choose> 
    <xsl:when test="??"> 
         <xsl:value-of select="somtext1"/> </xsl:when> 
    <xsl:otherwise> 
          <xsl:value-of select="somtext2"/> 
</xsl:otherwise> 
</xsl:choose>
</xsl:when>

谢谢。
2个回答

1

Use instead:

<xsl:when test="@Attrb2!='' and @Attrb2!=''">

Jim,我在发布这个问题之前已经尝试过了。它不起作用。我已经编辑了我的问题。谢谢。 - livehed
1
根据错误信息“预期令牌'eof'找到'!='”,我强烈怀疑您在某个地方引号不匹配。在那一点上,它不应该期望EOF。使用一个理解XML的好编辑器(Notepad++是一个合理的开始),并注意语法着色。 - Jim Garrison

1
或者使用:
<xsl:when test="not(@Attrb1='') and not(@Attrb2='')">

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接