Summer diet for your Notes Forms
One hallmark of Notes applications is their durability. It is quite common to find applications being in use, that root back into R3 or R4. Quite a number of these applications still look like that too. That's the flip-site of not needing to rip-and-replace. Sometimes you also will find, that older forms load slower and behave odd at times. Before you start beautifying your applications, it is a good idea to do some spring cleaning. To do so I use Domino's DXL to extract a form in XML, filter it through a XSLT transformation and reimport that into the database.
The LotusScript code is very straight forward, has been well covered on developer works and the help file and looks like this:
Set importer = session.CreateDXLImporter(stream, dbCopy)
importer.ReplicaRequiredForReplaceOrUpdate = False
importer.DesignImportOption = DXLIMPORTOPTION_CREATE
The "meat" is in the transformation. The XSLT file consist of 4 principal sections that contain templates. In section 1 we find the start of the output including the wrapper and calls to various templates. In section 2 design elements are filtered out, in section 3 design elements are tweaked, finally in section 4 the remaining DXL is copied 1:1 to the resulting document; . The sequence of the sections is not relevant, since XSLT uses priorities not sequence to determine what element to apply. What are the elements you can or should spring clean:
- In DXL I found NotesItems between the </body> and the </form> tag. Removing this from the form makes the form smaller, load faster without any change in behavior.
- Font information is encoded inside the <run> tag. The <run> tag is similar to HTML's <span>. When you designed and re-designed forms over and over, there will be <run> tags that only contain a font change, but not actual any characters. Filtering that out lightens the form
- Filter out all paragraph formats and/or fonts to be able to apply a new look & feel more easily
- Convert access controlled sections into subforms (to work in the web)
- Remove (all) LotusScript code and move it to libraries (see an upcoming SnTT post on "Classical Forms" about that).
Let us look at some code....ont size=2 face="sans-serif">Section 1 starts the whole stylesheet.
< ont=""> match="/">
Section 2 features match clauses with no content inside the template. It is closed in the opening tag using />. If a tag should be filtered, but its content be processed you just have the
< ont=""> match="d:run[node()[last()=1][self::d:font" />
<!-- Filter out items after the body tag -->
<xsl:template match="d:form/d:item" />
<!-- Filter out all font information : radical cut if you want to redo the fonts -->
<xsl:template match="d:font" />
(There is actually much more in the stylesheet, so check the sample stylesheet in the download section).
Section 3 features some tweaks to existing elements:
<!-- Add a hidden field for Debug information and update all hidden fields to use that formula instead of hide='read edit copy preview previewedit' -->
<pardef hide="read edit print copy preview previewedit">
<field type="number" kind="computedfordisplay" name="isNotDebug">
Check the stylesheet for more element tweaks and a few interesting concepts.
<!-- Replace all paragraph definition where hide='read edit copy preview previewedit' with hidewhen isNotDebug -->
match="d:pardefhide='read edit copy preview previewedit' or @hide='read edit print copy preview previewedit'quot;>
Section 4 has been used in many other examples before. It leverages on the fact, that the match="*" has the lowest priority and only is applied if there is no other suitable template:
<xsl:variable name="curTagname" select="name()"/>
<!-- Walk through the attributes -->
<!-- process the children -->
<xsl:variable name="curAttName" select="name()"/>
<!-- make sure nothing is copied in the additional modes if not defined by a template-->
<xsl:template mode="genSub" match="*"/>
<xsl:template mode="genLS" match="*"/>
Before you send back that DXL into a datbase you could scrub it further by removing pardef sections that have identical definitions. However this would require a second run with another stylesheet or some good old LotusScript code. <>