wissel.net

Usability - Productivity - Business - The web - Singapore & Twins

View selection reports


In the last entry I described a method to replace view selection formulas wholesale with boolean expressions. One question I got asked was: " Do we need this?". The clear answer is: " It depends". To make an informed decision, you need to look at your view selection formulas. To make that easier I designed a report you can run against your DXL export of your database design (using DXLMagic) that will highlight stuff that needs fixing. Of course beautiy is in the eye of the beholder. Eliminating @Now, @Today, @Tomorrow and @Yesterday is a no-brainer for anyone. Disputed items are @IsResponseDoc (you probably want @AllDescendants) or @Contains, as well as the total length or the number of *OR* conditions. Anyway, the report with a little automation can be part of your standard system documentation.
Sample for Selection Formula Report
The report is done in XSLT and you are free to add your own priorities in the matching formulas.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:d='http://www.lotus.com/dxl'
   xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="2.0">
   
    <xsl:template match="/">
        <html>
            <head><title>View selection formula Report </title>
            <style type="text/css">
                html, body, td { font-family : Verdana, Arial, sans-serif; font-size : small }
                td { margin : 5px, padding : 5px; border-right : 1px solid gray; border-bottom : 1px solid gray }
                th { margin : 5px, padding : 5px; border-right : 2px solid gray; border-bottom : 2px solid gray }
                .vname { color : black; background-color : #EEEEFF }
                .valias { color : black; background-color : #DDDDFF }
                .valiasmissing { color : black; background-color : #9999DD }                
                .vselect { color : black; background-color : #EEFFEE }
                .vselectbad { color : white; background-color : #FF0000 }
                .vselectfixit { color : black; background-color : #FFA200 }
            </style></head>
            <body>
                <h1>View selection formula Report </h1>
                <h2>for <xsl:value-of select="/d:database/@title" /> ( <xsl:value-of select="/d:database/@path" />) </h2>
                <table>
                    <thead>
                        <tr>
                            <th>View </th>
                            <th>Alias </th>
                            <th>Selection Formula </th>
                        </tr>
                    </thead>
                    <tbody>
                        <xsl:apply-templates select="/d:database/d:view"/>        
                    </tbody>
                   
                </table>
               
               
            </body>
        </html>
       
    </xsl:template>
   
    <xsl:template match="d:view">
        <tr>
            <td class="vname">
                <xsl:value-of select="@name" />
            </td>
            <xsl:choose>
                <xsl:when test="@alias">
                    <td class="valias">
                        <xsl:value-of select="@alias" />
                    </td>
                </xsl:when>
                <xsl:otherwise>
                    <td class="valiasmissing">
                       ./.
                    </td>
                </xsl:otherwise>
            </xsl:choose>
                <xsl:apply-templates select="d:code[@event='selection']/d:formula" />  
        </tr>
    </xsl:template>
   
    <xsl:template match="d:formula">
        <td class="vselect">
        <xsl:value-of select="." />
            </td>
    </xsl:template>
   
    <xsl:template match="d:formula[contains(text(),'@Now')]">
        <td class="vselectbad">
            <xsl:value-of select="." />
        </td>
    </xsl:template>
   
    <xsl:template match="d:formula[contains(text(),'@IsResponseDoc') and contains(text(),'!@IsResponseDoc')=false]">
        <td class="vselectfixit">
            <xsl:value-of select="." />
        </td>
    </xsl:template>
   
    <xsl:template match="d:formula[@test]">
        <td class="vselectfixit">
            <xsl:value-of select="." />
        </td>
    </xsl:template>
   
    <xsl:template match="d:formula[contains(text(),'@Today')]">
        <td class="vselectbad">
            <xsl:value-of select="." />
        </td>
    </xsl:template>
   
    <xsl:template match="d:formula[contains(text(),'@ViewTitle')]">
        <td class="vselectfixit">
            <xsl:value-of select="." />
        </td>
    </xsl:template>
   
</xsl:stylesheet>
 
If you just want the view selection formulas, you can use some LotusScript too. The report is most handy when you have the DXL export around anyway. As usual YMMV.

Posted by on 29 November 2011 | Comments (0) | categories: Show-N-Tell Thursday

Comments

  1. No comments yet, be the first to comment