【问题标题】:SharePoint XSLT Problem -SharePoint XSLT 问题 -
【发布时间】:2010-03-04 00:20:19
【问题描述】:

我正在尝试突出显示某些 SharePoint XSLT 结果。下面是我得到的 XML。 我遇到的问题是模板匹配块与 UM 的子节点不匹配如果有人能看到我哪里出错了,那就太好了。

谢谢

克里斯

        <rows>
          <row>
            <LastModifiedTime>02/25/2010 18:32:25</LastModifiedTime>
            <RANK>325</RANK>
            <TITLE>UMUK Win At The Mobile Entertainment</TITLE>
            <AUTHOR>SVR08-002\Administrator</AUTHOR>
            <CREATED>02/25/2010 18:32:22</CREATED>
            <PATH>http://svr08-002:7005/Lists/FrontPageNews/DispForm.aspx?ID=3</PATH>
            <HitHighlightedSummary>a
              <c0>UM</c0> UK won the category of Best Music Label 2009 at the 4th annual ME (Mobile Entertainment) Awards C <ddd/>
            </HitHighlightedSummary>
          </row>
        </rows>

这是我目前拥有的 XSLT。

          <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >

        <xsl:template match="/">

          <table class="ICS_SearchTable" cellpadding="0" cellspacing="0" width="100%">
            <xsl:for-each select="rows/row">

              <xsl:variable name="Ext">
                <xsl:call-template name="get-file-extension">
                  <xsl:with-param name="path" select="substring-before(PATH, '?')" />
                </xsl:call-template>
              </xsl:variable>      
              <tr>
                <td width="10%">

                </td>
                <td>
                    <div class="ICS_SearchResultItem">
                        <div class="ICS_SearchResultItemImage">
                        <img src="/Style Library/UMIGlobe/Styles/Images/Common/umgi-{$Ext}.png" alt="{$Ext}"/>
                        </div>
                        <div class="ICS_SearchResultItemTitle">
                                    <a href="{PATH}"><xsl:value-of select="TITLE"/></a>
                        </div>
                        <div class="ICS_SearchResultItemDesc">
                      <xsl:choose>
                      <xsl:when test="HitHighlightedSummary[. != '']">
                         <xsl:call-template name="HitHighlighting">
                            <xsl:with-param name="hh" select="HitHighlightedSummary" /> 
                         </xsl:call-template> 
                      </xsl:when>   
                       <xsl:when test="DESCRIPTION[. != '']">
                          <xsl:value-of select="DESCRIPTION"/>     
                       </xsl:when>     
                      </xsl:choose>
                        </div>
                        <div class="ICS_SearchResultItemLink">
                                    <a href="{PATH}"><xsl:value-of select="PATH"/></a> - <xsl:value-of select="AUTHOR" /> - <xsl:value-of select="LastModifiedTime"/>
                      <xsl:call-template name="DisplaySize">
                        <xsl:with-param name="size" select="SIZE" />
                      </xsl:call-template>                                          
                        </div>                                                                              
                            </div>                                  
                </td>
              </tr>
            </xsl:for-each>
          </table>  
        </xsl:template>

        <xsl:template name="HitHighlighting">
          <xsl:param name="hh" />
          <xsl:apply-templates select="$hh"/>
        </xsl:template>

        <xsl:template match="ddd">
          &#8230;
        </xsl:template>
        <xsl:template match="c0">
          <b>
            <xsl:value-of select="."/>
          </b>
        </xsl:template>
        <xsl:template match="c1">
          <b>
            <xsl:value-of select="."/>
          </b>
        </xsl:template>
        <xsl:template match="c2">
          <b>
            <xsl:value-of select="."/>
          </b>
        </xsl:template>
        <xsl:template match="c3">
          <b>
            <xsl:value-of select="."/>
          </b>
        </xsl:template>
        <xsl:template match="c4">
          <b>
            <xsl:value-of select="."/>
          </b>
        </xsl:template>
        <xsl:template match="c5">
          <b>
            <xsl:value-of select="."/>
          </b>
        </xsl:template>
        <xsl:template match="c6">
          <b>
            <xsl:value-of select="."/>
          </b>
        </xsl:template>
        <xsl:template match="c7">
          <b>
            <xsl:value-of select="."/>
          </b>
        </xsl:template>
        <xsl:template match="c8">
          <b>
            <xsl:value-of select="."/>
          </b>
        </xsl:template>
        <xsl:template match="c9">
          <b>
            <xsl:value-of select="."/>
          </b>
        </xsl:template>  

      <!-- The size attribute for each result is prepared here -->
      <xsl:template name="DisplaySize">
        <xsl:param name="size" /> 
        <xsl:if test='string-length($size) &gt; 0'>       
         <xsl:if test="number($size) &gt; 0">
         -
          <xsl:choose>
           <xsl:when test="round($size div 1024) &lt; 1"><xsl:value-of select="$size" /> Bytes</xsl:when>
           <xsl:when test="round($size div (1024 *1024)) &lt; 1"><xsl:value-of select="round($size div 1024)" />KB</xsl:when>
           <xsl:otherwise><xsl:value-of select="round($size div (1024 * 1024))"/>MB</xsl:otherwise>
          </xsl:choose>    
         </xsl:if>
        </xsl:if>
      </xsl:template>  

        <xsl:template name="get-file-extension">
          <xsl:param name="path" />
          <xsl:choose>
            <xsl:when test="contains( $path, '/' )">
              <xsl:call-template name="get-file-extension">
                <xsl:with-param name="path" select="substring-after( $path, '/' )" />
              </xsl:call-template>
            </xsl:when>
            <xsl:when test="contains( $path, '.' )">
              <xsl:call-template name="get-file-extension">
                <xsl:with-param name="path" select="substring-after( $path, '.' )" />
              </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
              <!-- SET THE PATH IMAGE SRC -->
              <xsl:choose>
                <xsl:when test="$path = 'uk' or $path = 'org' or $path = 'com' or $path = 'net' or $path = 'biz' or $path = 'gov'">
                  <xsl:text>url</xsl:text>
                </xsl:when>
                <xsl:otherwise>
                  <xsl:value-of select="$path" />
                </xsl:otherwise>
              </xsl:choose>
            </xsl:otherwise>
          </xsl:choose>
        </xsl:template>  
      </xsl:stylesheet>

【问题讨论】:

    标签: sharepoint xslt sharepoint-2007


    【解决方案1】:

    “UM 的子节点”是什么意思?

    也许我遗漏了一些东西,但没有名为“UM”的节点,只有文本。那么你的意思是要匹配包含文本“UM”的节点......换句话说&lt;c0&gt;UM&lt;/c0&gt;

    在我的例子中,当我运行你的样式表时,它确实匹配了&lt;c0&gt; 节点,并写入了一个&lt;b&gt; 节点。

    &lt;b&gt;UM&lt;/b&gt; UK won the category of Best Music Label 2009 at the 4th annual ME (Mobile Entertainment) Awards C

    什么不适合你?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2010-09-29
      • 1970-01-01
      • 1970-01-01
      • 2010-12-19
      • 1970-01-01
      • 2018-03-31
      • 2010-11-10
      • 1970-01-01
      相关资源
      最近更新 更多