2011-03-25 73 views
0

我在寻找一些帮助的XSL选择:XSL在那里声明

我需要的是一个选择,将显示一个不同的列表标题在同一行的文档匹配名称字段。如果没有条目,我会显示一个链接来创建一个新链接。这里是我有:

<xsl:choose> 
    <xsl:when test="/dsQueryResponse 
         /Change_Types 
          /Rows 
          /Row 
           /@Document = @Name"/> 
     <xsl:value-of select="/dsQueryResponse 
           /Change_Types 
            /Rows 
             /Row 
              /@Document[ 
               /dsQueryResponse 
               /Change_Types 
                /Rows 
                 /Row 
                  /@Document = @Name 
              ]"/> 
    </xsl:when> 
    <xsl:otherwise> 
     <!-- Code to show link --> 
    </xsl:otherwise> 
</xsl:choose> 

如果任何人都可以指出我要去哪里错了,将不胜感激!

+1

请张贴您输入的XML。 – 2011-03-25 18:52:48

+2

该谓词将始终为false,因为从来没有'@ Document'属性具有'@ Name'属性。请发布您的XML文档。 – 2011-03-25 22:00:40

回答

0

以下是我的工作方式: 需要为@FileLeafRef创建一个变量,以便可以保留该变量以在for-each内进行测试。

<xsl:variable name="document" select="@FileLeafRef"/> 

<xsl:choose> 
<!-- If there is an entry in the 'Tickets' list for this @FileLeafRef --> 
<xsl:when test="/dsQueryResponse/Tickets/Rows/Row/@Document = $document"> 
    <!-- Show it here --> 
    <xsl:for-each select="/dsQueryResponse/Tickets/Rows/Row"> 
     <xsl:if test="@Document = $document"> 
     <xsl:value-of select="@Title"/> 
    </xsl:if> 
     </xsl:for-each> 
</xsl:when> 
<!-- Else, show a link to add a new Ticket with the document auto-populated --> 
<xsl:otherwise> 
    <xsl:call-template name="addNewItemLink"> 
     <xsl:with-param name="list" select="'Tickets'"/> 
     <xsl:with-param name="document" select="@FileLeafRef"/> 
    </xsl:call-template> 
</xsl:otherwise> 
</xsl:choose> 
2

在没有你的源XML它是一个完整的猜测,但我怀疑

@Document = @Name 

应该

@Document = current()/@Name 

两个场合。除非您确实希望同一元素的DocumentName属性具有相同的值。