【发布时间】:2015-09-22 16:45:45
【问题描述】:
我正在一个程序中处理 XSLT,它使用 XML 1.0。所以,因为它在一个程序中,所以我不能使用其他语言来做到这一点。 在程序中,我可以选择一些关于我的数据的选项,但我无法从 xslt 获取它。代码现在是这样的:
<!-- MD_DataIdentification.topicCategory-->
<div class="itemInfo">
<span style="color: black; font-size: 13;">
<span style="color: black; font-size: 15; font-weight:bold;">Categoria temática:<br /></span>
<xsl:choose>
<xsl:when test="/metadata/dataIdInfo[1]/tpCat/TopicCatCd[(. != '001') and (. != '002') and (. != '003') and (. != '004') and (. != '005') and (. != '006') and (. != '007') and (. != '008') and (. != '009') and (. != '010')]">
<xsl:for-each select="/metadata/dataIdInfo[1]/tpCat/TopicCatCd[(. != '001') and (. != '002') and (. != '003') and (. != '004') and (. != '005') and (. != '006') and (. != '007') and (. != '008') and (. != '009') and (. != '010')]">
<xsl:value-of select="."/>
<xsl:if test="not(position()=last())">, </xsl:if>
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
<span class="noContent">No information (mandatory)</span>
</xsl:otherwise>
</xsl:choose>
</span>
</div>
我从“for-each”中得到的答案是我选择的一些空格。我想做的是将代码与它所代表的信息相关联。比如 001 = 农业,002 = 生物,003 = 经济,等等。任何人都可以帮助我吗?如何强制 xslt 显示代码名称? 我尝试执行此代码,但它不起作用:
<xsl:choose>
<xsl:when test="/metadata/dataIdInfo[1]/tpCat/TopicCatCd[(. != '001') and (. != '002') and (. != '003') and (. != '004') and (. != '005') and (. != '006') and (. != '007') and (. != '008') and (. != '009') and (. != '010')]">
<xsl:if test="/metadata/dataIdInfo[1]/tpCat/TopicCatCd[(. != '001')]">
Farming |
</xsl:if>
<xsl:if test="/metadata/dataIdInfo[1]/tpCat/TopicCatCd[(. != '002')]">
Biologic |
</xsl:if>
<xsl:if test="/metadata/dataIdInfo[1]/tpCat/TopicCatCd[(. != '003')]">
Boundaries |
</xsl:if>
<xsl:if test="/metadata/dataIdInfo[1]/tpCat/TopicCatCd[(. != '004')]">
Atmospheric |
</xsl:if>
<xsl:if test="/metadata/dataIdInfo[1]/tpCat/TopicCatCd[(. != '005')]">
Economy |
</xsl:if>
</xsl:when>
</xsl:choose>
但是当我使用它时,我会收到所有未导入的名称,无论它是否被选中。 如果有人可以帮助我,我将不胜感激。 :)
我还有一个问题。在这个 中,重点是什么?谢谢!
【问题讨论】:
-
您能否包含一个示例 XML 文档? XPath 中的点
.是当前节点的别名。