zoukankan      html  css  js  c++  java
  • Sharepoint2007 dataformwebpart制作单元测试仪表板

    背景:BI team需要制作单元测试仪表板,可参考模板的总体任务仪表板

    模板的总体任务仪表板:

    发现问题:

       

    1经过了解,此仪表板并非moss的KPI webpart,查看总体任务仪表板,发现其是一个数据视图,由此可排除其他部件.

       

    2但问题是一般的数据视图并没有仪表板这样突出显示百分比的功能.此问题是解决这个任务的关键.

       

       

    分析问题:

       

    3.观察数据视图的结构,发现里面存在xslt编辑源.里面的显示格式,及获取数据的方法就是从这里写的.

       

    4.要想获得与总体任务相同的显示效果,就得修改xslt的数据提取方法及显示样式.

       

    5.根据状态里面的选项,与总体任务的状态对比,由此可以作出修改.

       

    <xsl:stylesheet xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" version="1.0" exclude-result-prefixes="xsl msxsl ddwrt" xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:WebControls="Microsoft.SharePoint.WebControls" xmlns:ddwrt2="urn:frontpage:internal">

    <xsl:output method="html" indent="no"/>

    <xsl:decimal-format NaN="NaN"/>

    <xsl:param name="dvt_apos">&apos;</xsl:param>

    <xsl:variable name="dvt_1_automode">0</xsl:variable>

    <xsl:template match="/" xmlns:x="http://www.w3.org/2001/XMLSchema" xmlns:d="http://schemas.microsoft.com/sharepoint/dsp" xmlns:asp="http://schemas.microsoft.com/ASPNET/20" xmlns:__designer="http://schemas.microsoft.com/WebParts/v2/DataView/designer" xmlns:WebControls="Microsoft.SharePoint.WebControls">

    <xsl:call-template name="dvt_1"/>

    </xsl:template>

    <xsl:template name="dvt_1">

    <xsl:param name="ParentPath"/>

    <xsl:variable name="dvt_StyleName">Table</xsl:variable>

    <xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row"/>

    <xsl:variable name="dvt_RowCount" select="count($Rows)" />

    <xsl:variable name="IsEmpty" select="$dvt_RowCount = 0" />

    <xsl:call-template name="dvt_1.footer">

    <xsl:with-param name="Rows" select="$Rows" />

    </xsl:call-template>

    </xsl:template>

    <xsl:template name="dvt_1.body">

    <xsl:param name="ParentPath"/>

    <xsl:param name="Rows"/>

    <xsl:for-each select="$Rows">

    <xsl:variable name="SrcPos" select="count(preceding-sibling::*[local-name()=local-name(current()) and namespace-uri()=namespace-uri(current())])+1" />

    <xsl:call-template name="dvt_1.rowview">

                <xsl:with-param name="ParentPath" select="$ParentPath" />

                <xsl:with-param name="SrcPos" select="$SrcPos" />

    </xsl:call-template>

    </xsl:for-each>

    </xsl:template>

    <xsl:template name="dvt_1.rowview">

    <xsl:param name="ParentPath"/>

    <xsl:param name="SrcPos"/>

    </xsl:template>

    <xsl:template name="percentformat">

        <xsl:param name="percent"/>

    <xsl:choose>

    <xsl:when test="format-number($percent, '#,##0%;-#,##0%')= 'NaN'">0%</xsl:when>

    <xsl:otherwise>

    <xsl:value-of select="format-number($percent, '#,##0%;-#,##0%')" />

    </xsl:otherwise>

    </xsl:choose>

    </xsl:template>

    <xsl:template name="dvt_1.footer">

    <xsl:param name="ParentPath" />

    <xsl:param name="Rows" />

          

          

          

    <xsl:variable name="DEFINED" select="count(/dsQueryResponse/Rows/Row[normalize-space(@_x72b6__x6001_) = 'DEFINED'])" />

    <xsl:variable name="VERIFIED" select="count(/dsQueryResponse/Rows/Row[normalize-space(@_x72b6__x6001_) = 'VERIFIED'])" />

    <xsl:variable name="VERIFIEDTwo" select="count(/dsQueryResponse/Rows/Row[normalize-space(@_x72b6__x6001_) = 'VERIFIED Two'])" />

    <xsl:variable name="CREATED" select="count(/dsQueryResponse/Rows/Row[normalize-space(@_x72b6__x6001_) = 'CREATED'])" />

    <xsl:variable name="PASSED" select="count(/dsQueryResponse/Rows/Row[normalize-space(@_x72b6__x6001_) = 'PASSED'])" />

         <xsl:variable name="FAILED" select="count(/dsQueryResponse/Rows/Row[normalize-space(@_x72b6__x6001_) = 'FAILED'])" />

          

    <xsl:variable name="AllTasks" select="count(/dsQueryResponse/Rows/Row)" />

    <xsl:variable name="percentDEFINED" select="$DEFINED div $AllTasks" />

    <xsl:variable name="percentVERIFIED" select="$VERIFIED div $AllTasks" />

    <xsl:variable name="percentVERIFIEDTwo" select="$VERIFIEDTwo div $AllTasks" />

    <xsl:variable name="percentPASSED" select="$PASSED div $AllTasks" />

    <xsl:variable name="percentCREATED" select="$CREATED div $AllTasks" />

        <xsl:variable name="percentFAILED" select="$FAILED div $AllTasks" />

    <table width="100%" cellspacing="0" cellpadding="2" style="border-right: 1 solid #C0C0C0; border-bottom: 1 solid #C0C0C0; border-left-style: solid; border-left- 1; border-top-style: solid; border-top- 1;">

    <tr>

    <td class="ms-formbody" width="125px" style="vertical-align:middle">

    DEFINED: <xsl:value-of select="$DEFINED" />

    <xsl:text xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:nbsp-preserve="yes" disable-output-escaping="yes">&amp;nbsp; </xsl:text>(

    <xsl:call-template name="percentformat">

    <xsl:with-param name="percent" select="$percentDEFINED"/>

    </xsl:call-template>

          

          

    )

    </td>

    <td>

    <table width="100%" >

    <tr>

    <td width="{round($percentDEFINED*100)+1}%" height="15px" class="ms-selected">

    </td>

    <td width="100%" >

    </td>

    </tr>

    </table>

    </td>

    </tr>

    <tr>

    <td class="ms-formbody" width="125px" style="vertical-align:middle">

    VERIFIED: <xsl:value-of select="$VERIFIED" />

    <xsl:text xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:nbsp-preserve="yes" disable-output-escaping="yes">&amp;nbsp; </xsl:text>(

    <xsl:call-template name="percentformat">

    <xsl:with-param name="percent" select="$percentVERIFIED"/>

    </xsl:call-template>

          

          

    )

    </td>

    <td>

    <table width="100%" >

    <tr>

    <td width="{round($percentVERIFIED*100)+1}%" height="15px" class="ms-selected">

    </td>

    <td width="100%" >

    </td>

    </tr>

    </table>

    </td>

    </tr>

    <tr>

    <td class="ms-formbody" width="125px" style="vertical-align:middle">

    VERIFIED Two: <xsl:value-of select="$VERIFIEDTwo" />

    <xsl:text xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:nbsp-preserve="yes" disable-output-escaping="yes">&amp;nbsp; </xsl:text>(

    <xsl:call-template name="percentformat">

    <xsl:with-param name="percent" select="$percentVERIFIEDTwo"/>

    </xsl:call-template>

          

    )

    </td>

    <td>

    <table width="100%" >

    <tr>

    <td width="{round($percentVERIFIEDTwo*100)+1}%" height="15px" class="ms-selected">

    </td>

    <td width="100%" >

    </td>

    </tr>

    </table>

    </td>

    </tr>

    <tr>

    <td class="ms-formbody" width="125px" style="vertical-align:middle">

    PASSED: <xsl:value-of select="$PASSED" />

    <xsl:text xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:nbsp-preserve="yes" disable-output-escaping="yes">&amp;nbsp; </xsl:text>(

    <xsl:call-template name="percentformat">

    <xsl:with-param name="percent" select="$percentPASSED"/>

    </xsl:call-template>

          

    )

    </td>

    <td>

    <table width="100%" >

    <tr>

    <td width="{round($percentPASSED*100)+1}%" height="15px" class="ms-selected">

    </td>

    <td width="100%" >

    </td>

    </tr>

    </table>

    </td>

    </tr>

    <tr>

    <td class="ms-formbody" width="125px" style="vertical-align:middle">

    CREATED: <xsl:value-of select="$CREATED" />

    <xsl:text xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:nbsp-preserve="yes" disable-output-escaping="yes">&amp;nbsp; </xsl:text>(

    <xsl:call-template name="percentformat">

    <xsl:with-param name="percent" select="$percentCREATED"/>

    </xsl:call-template>

        

    )

    </td>

    <td>

    <table width="100%" >

    <tr>

    <td width="{round($percentCREATED*100)+1}%" height="15px" class="ms-selected">

    </td>

    <td width="100%" >

    </td>

    </tr>

    </table>

    </td>

    </tr>

    <tr>

    <td class="ms-formbody" width="125px" style="vertical-align:middle">

    FAILED: <xsl:value-of select="$FAILED" />

    <xsl:text xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime" ddwrt:nbsp-preserve="yes" disable-output-escaping="yes">&amp;nbsp; </xsl:text>(

    <xsl:call-template name="percentformat">

    <xsl:with-param name="percent" select="$percentFAILED"/>

    </xsl:call-template>

          

    )

    </td>

    <td>

    <table width="100%" >

    <tr>

    <td width="{round($percentFAILED*100)+1}%" height="15px" class="ms-selected">

    </td>

    <td width="100%" >

    </td>

    </tr>

    </table>

    </td>

    </tr>

          

    </table>

    </xsl:template>

    <xsl:template name="dvt_1.header">

    <xsl:param name="ParentPath" />

    <xsl:param name="Rows" />

    <table cellSpacing="0" cellPadding="2" border="0" width="365px" >

    <tr>

    <td class="ms-formfieldlabel">

    <p>

    <strong>总体单元测试状态</strong>

    </p>

    </td>

    </tr>

    </table>

    </xsl:template>

    </xsl:stylesheet>

        

       

     解决问题:

    6.修改了xslt源,还是无法正常显示百分比.由此想到,是不是列表的层次过多,无法显示.

       

    测试情况1.,测试另一个无层次列表,发现正常.说明xslt源正确.

       

    测试情况2,只提取一个状态值.发现还是不行.说明有得没显示.

       

    测试情况3,datawebform 属性,选择显示所有行.此时可以了.

     

       

       

       

    作者:johnny 出处:http://www.cnblogs.com/sunjunlin 本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。
  • 相关阅读:
    XAML学习笔记之Layout(五)——ViewBox
    XAML学习笔记——Layout(三)
    XAML学习笔记——Layout(二)
    XAML学习笔记——Layout(一)
    从0开始搭建SQL Server 2012 AlwaysOn 第三篇(安装数据,配置AlwaysOn)
    从0开始搭建SQL Server 2012 AlwaysOn 第二篇(配置故障转移集群)
    从0开始搭建SQL Server 2012 AlwaysOn 第一篇(AD域与DNS)
    Sql Server 2012 事务复制遇到的问题及解决方式
    Sql Server 2008R2升级 Sql Server 2012 问题
    第一次ACM
  • 原文地址:https://www.cnblogs.com/sunjunlin/p/1795713.html
Copyright © 2011-2022 走看看