1
我正在使用Umbraco并在XSLT中遇到了一些问题。xslt - 获取子节点下的节点类型
我有以下结构:
root
nodeA
nodeB
nodeB
nodeB
nodeC
nodeA
nodeB
nodeB
nodeB
我希望能够在根或nodeA上nodeC上从下得到了nodeA节点B。
我目前使用以下方法:
<xsl:param name="currentPage"/>
<xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::*/nodeC" />
<xsl:template match="/">
<!-- start writing XSLT -->
<xsl:for-each select="$siteRoot/ancestor-or-self::*/nodeA/nodeB">
<xsl:if test="string(umbracoNaviHide) != '1'">
<li style="background-image: none;">
<xsl:if test="position() = last()">
<xsl:attribute name="class">no-border</xsl:attribute>
</xsl:if>
<a>
<xsl:attribute name="href">
<xsl:value-of select="umbraco.library:NiceUrl(current()/@id)"/>
</xsl:attribute>
<xsl:attribute name="style">
text-decoration: none;
</xsl:attribute>
<xsl:value-of select="./Name" /></a></li>
</xsl:if>
</xsl:for-each>
</xsl:template>
@Dimire - 有关XPath的书在阅读列表中。在MVC3之后,实体框架和Objective-C :) –