Tuesday, April 22, 2008

Notes/Domino Formula Diagnosis

Been really busy with a workflow project so not alot of spare time for blogging, though I did want to share a handy technique I discovered. The project is mostly completed, but because of requested tweaks, I was afraid I was breaking some of my view formulas (both view selection and column formulas). I needed a way to quickly view my formulas without opening up each one and clicking around everywhere. In as much as I would love to be the proud owner of a Ytria ViewEZ copy or one of Teamstudio's wonderful products, I resorted to the duct tape and string approach by using good old DXL.

If you're not up to speed with XML, stop by the W3 Schools site and brush up on XSL/XSLT and XPath. Next, get yourself a couple good tools. You'll need your favorite text editor and something to evaluate the XML DOM and to help with XPath. I use the DOM Inspector inside FireFox, and the XPather Browser FireFox add-on. In this particular example I pulled out view design objects using Domino Designer and exported them to DXL. (I also have Ytria's ScanEZ which makes DXL exporting easy too.)

Once you have your XML, you need to open it up in your favorite text editor. Remove the xmlns attribute name/value pair from the database tag (this confuses the stylesheet transformation for some reason). Add in the XML stylesheet refrence:
<?xml-stylesheet type="text/xsl" href="ColFormulas.xsl"?>
right after the top tag. Now all you need is the stylesheet. Here's the one I used:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2><xsl:value-of select="database/@title"/> Column Formulas</h2>
<table border="1" width="500">
<tr bgcolor="#9acd32">
<th align="left" >Column Header</th>
<th align="left" >Formula</th>
</tr>
<xsl:for-each select="/database/view">
<tr bgcolor="#eaeaea">
<td colspan="2"><b><xsl:value-of select="@name"/></b>; Selection Formula: <xsl:value-of select="code/formula"/></td>
</tr>
<xsl:for-each select="column">
<tr>
<td><xsl:value-of select="columnheader/@title"/></td>
<td><xsl:value-of select="code/formula"/></td>
</tr>
</xsl:for-each>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
Save both the files and open up the DXL file in FireFox. You should see a nice HTML page listing all your views with their selection formulas and underneath them a listing of all the columns and their formulas.

0 comments: