Xml 如何访问if语句XSLT中的嵌套元素
所以我需要访问if语句中的嵌套元素 下面您可以看到我正在使用的XML示例:Xml 如何访问if语句XSLT中的嵌套元素,xml,if-statement,dom,xslt,Xml,If Statement,Dom,Xslt,所以我需要访问if语句中的嵌套元素 下面您可以看到我正在使用的XML示例: <Publication> <PubName>Avoid the Consumer Apps - How to Collaborate Securely and Productively in the Finance Sector</PubName> <Attributes> <Attribute> <AttributeNam
<Publication>
<PubName>Avoid the Consumer Apps - How to Collaborate Securely and Productively in the Finance Sector</PubName>
<Attributes>
<Attribute>
<AttributeName>Type</AttributeName>
<Value>Webinar</Value>
<ValueText>Webinar</ValueText>
</Attribute>
</Attributes>
</Publication>
但这不会返回任何结果,因此我想知道如何访问
Value
元素?对Value
元素使用谓词,如下所示:
<xsl:for-each select="TradePub.com/PublicationTable/Publication">
<xsl:if test="Attributes/Attribute[Value!='Webinar']">
<tr>
<td><xsl:value-of select="PubName"/></td>
<td><xsl:value-of select="PubCode"/></td>
</tr>
</xsl:if>
</xsl:for-each>
没有得到任何输出的另一个问题是,示例中的IF子句为FALSE。要获得给定样本的所需输出,请使用
<xsl:if test="Attributes/Attribute[Value='Webinar']">
相反。然后,输出将是
<tr>
<td>Avoid the Consumer Apps - How to Collaborate Securely and Productively in the Finance Sector</td>
<td/> <!-- No 'PubCode' element present -->
</tr>
避免使用消费者应用程序-如何在金融领域安全高效地协作
由于Value
的内容等于“Webinar”,因此if表达式的计算结果为false,不会产生任何输出。你期待什么?请发一封邮件。无法使用(编辑过的)代码再现此问题:
<tr>
<td>Avoid the Consumer Apps - How to Collaborate Securely and Productively in the Finance Sector</td>
<td/> <!-- No 'PubCode' element present -->
</tr>