xslt-获取子节点下的节点类型

xslt-获取子节点下的节点类型,xslt,xpath,umbraco,Xslt,Xpath,Umbraco,我正在使用Umbraco,但在XSLT方面遇到了一些问题 我的结构如下: root nodeA nodeB nodeB nodeB nodeC nodeA nodeB nodeB nodeB 我希望能够从根下的nodeA或nodeC下的nodeA获得nodeB 我目前使用以下方法: <xsl:param name="currentPage"/> <xsl

我正在使用Umbraco,但在XSLT方面遇到了一些问题

我的结构如下:

root
   nodeA
      nodeB
      nodeB
      nodeB
   nodeC
      nodeA
         nodeB
         nodeB
         nodeB
我希望能够从根下的nodeA或nodeC下的nodeA获得nodeB

我目前使用以下方法:

 <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>

  • 无边界
  • 注意:尽可能避免使用XPath
    子体:
    子体或self:
    轴或
    /
    伪运算符——它们会导致显著的效率低下(执行缓慢),并且与
    /
    一起使用时会出现异常和违反直觉的行为操作员


    注意:尽可能避免使用XPath
    子体:
    子体或self:
    轴或
    /
    伪运算符——它们会导致显著的效率低下(执行缓慢),并且与
    /
    一起使用时会出现异常和违反直觉的行为operator.

    @Dimire-阅读清单上有一本关于XPath的书。就在MVC3、实体框架和Objective-C:)@Dimire之后,一本关于XPath的书出现在阅读列表上。就在MVC3、实体框架和Objective-C之后:)
    <xsl:param name="currentPage"/> 
        <xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::*/nodeC" /> 
    .  .  .  
      <xsl:for-each select="$siteRoot/ancestor-or-self::*/nodeA/nodeB">
    
      <xsl:param name="currentPage"/> 
          <xsl:variable name="siteRoot" select="$currentPage/descendant-or-self::nodeC[1]" /> 
      .  .  .  
        <xsl:for-each select="$siteRoot/nodeA/nodeB">
    
    $currentPage/*/nodeC[1]/nodeA/nodeB