Domino Upgrade

VersionSupport end
5.0
6.0
6.5
7.0
Upgrade to 8.5x now!
(see the full Lotus lifcyle) To make your upgrade a success use the Upgrade Cheat Sheet. Contemplating to replace Notes? You have to read this!

Search

Reference

1. Learn XPages online
2. Communicate with IBMers and Lotus Experts using Sametime

About Me

I am the "IBM Collaboration & Productivity Advisor" for IBM Asia Pacific. I'm based in Singapore.
Reach out to me via:
Follow notessensei on Twitter
(posts)
Skype
Sametime
IBM
Facebook
LinkedIn
XING
Amazon Store
Amazon Kindle

Mobile tag

Twitter

Languages

Other languages on request.

Visitors

Useful Tools

Get Firefox
Use OpenDNS
The support for Windows XP is coming to an end and has . Time to consider an alternative to move on. sounds like a lot of time, but, like an object in a mirror, it is closer than you think.

« Five things you don't know about me | Main| A CRUD webservice - Part 2 »

Summer diet for your Notes Forms

QuickImage The title I wanted to give this post was "Spring clean your notes forms", but then it did get delayed....
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
 Call importer.Process


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.
  match="/">
       
           
            name="replicaid">
               
                select="/child::node()[1]/@replicaid"/>
           
            name="version">
               
                select="/child::node()[1]/@version"/>
           
           
             select="@*"/>
           
            />
           
            mode="genSub" />
            mode="genLS" />
       
       
   


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 statement as the only content.
   
    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:
 <xsl:template match="d:richtext">
        <richtext>
            <!-- Add a hidden field for Debug information and update all hidden fields to use that formula instead of hide='read edit copy preview previewedit' -->
            <xsl:if test="count(//d:fieldname='isNotDebug'=0">
                <pardef hide="read edit print copy preview previewedit">
                    <xsl:attribute name="id">
                        <xsl:value-of select="$pardefcount"/>
                    </xsl:attribute>
                </pardef>
                <par>
                    <xsl:attribute name="def">
                        <xsl:value-of select="$pardefcount"/>
                    </xsl:attribute>
                    <run>
                        <font color="red"/>
                        <field type="number" kind="computedfordisplay" name="isNotDebug">
                            <code event="defaultvalue">
                                <formula>@isNotMember("ebugquot;;@UserRoles)</formula>
                            </code>
                        </field>
                    </run>
                </par>
            </xsl:if>
            <xsl:apply-templates/>
        </richtext>
    </xsl:template>

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 -->
    <xsl:template
        match="d:pardefhide='read edit copy preview previewedit' or @hide='read edit print copy preview previewedit'quot;>
        <pardef>
            <xsl:attribute name="id">
                <xsl:value-of select="@id"/>
            </xsl:attribute>
            <code event="hidewhen">
                <formula>isNotDebug</formula>
            </code>
        </pardef>
    </xsl:template>

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:template match="*">
        <xsl:variable name="curTagname" select="name()"/>
        <xsl:element name="$curTagname">
            <!-- Walk through the attributes -->
            <xsl:apply-templates select="@*"/>
            <!-- process the children -->
            <xsl:apply-templates/>
        </xsl:element>
    </xsl:template>

    <xsl:template match="@*">
        <xsl:variable name="curAttName" select="name()"/>
        <xsl:attribute name="$curAttName">
            <xsl:value-of select="."/>
        </xsl:attribute>
    </xsl:template>

    <!-- 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.

Comments

Gravatar Image1 - thanx for this nice <a href="{ Link } article..

Gravatar Image2 - Didn't you get some problems with this DXL-turn-around? Layout regions? (Shared) Action? Additional or missing line breaks?

Which version of Notes do you use?

Thomas
http://www.assono.de/blog.nsf/

Post A Comment

Please note: Comments without a valid and working eMail address will be removed. This is my site, so I decide what stays here and what goes.

:-D:-o:-p:-x:-(:-):-\:angry::cool::cry::emb::grin::huh::laugh::rolleyes:;-)

Disclaimer

This site is in no way affiliated, endorsed, sanctioned, supported, nor enlightened by Lotus Software nor IBM Corporation. I may be an employee, but the opinions, theories, facts, etc. presented here are my own and are in now way given in any official capacity. In short, these are my words and this is my site, not IBM's - and don't even begin to think otherwise. (Disclaimer shamelessly plugged from Rocky Oliver)
© 2003 - 2012 Stephan H. Wissel - all rights reserved as listed here: Creative Commons License
Unless otherwise labeled by its originating author, the content found on this site is made available under the terms of an Attribution/NonCommercial/ShareAlike Creative Commons License, with the exception that no rights are granted -- since they are not mine to grant -- in any logo, graphic design, trademarks or trade names of any type.