Search
Categories
Tags
Latest Comments
« Sample NSF of XPage Login Control | Main | Where Are You in Your XPages Deployment Strategy? »
Thursday
Jul232009

Transforming Domino Forms into XPages via XSLT

I have been working with XML/XSLT for a long time and it is one of my favorite technologies to work with.  When developing XPages from existing form designs, or even ones I created to be the data source for a new XPage, there were a couple of things I noticed.

  1. The fields are always added in alphabetical order versus the order they appear on the Domino Form design.
  2. You have to change the control type to match the one on the Domino form when you drag the fields on the XPage from the data palette or they are all added as Edit Box controls
  3. Computed fields are not brought across at all.
  4. There was no way to create Radio or Checkbox keyword fields dynamically
  5. Keyword field values were not brought across at all

So, I found that every time I was adding fields to an XPage I had to

  1. Reorder the fields and Lables in the Table
  2. Add the Computed fields
  3. Change the controls that should be Radio Button and CheckBox controls manually
  4. Populate the choices for the selection type controls.

Ok, so first off let me be clear.  These are NOT difficult or time consuming tasks.  But my theory was if I didn't have to do those things every time then I could concentrate on the development of the XPage logic and not what are mostly mundane tasks.

So here is the premise.  The Domino Form Design can be expressed as XML (DXL officially).  An XPage is nothing more than well formed XML (JSP/JSF syntax).  So why not simply use XSLT (That's already built into the designer client) to transform the Domino Forms DXL output to the XPage XML output on the fly.

So I wrote an XSLT (XML Stylesheet Trasformation) file that will perform the transformation.

One aspect that I like about this current solution is that the XSLT file is installed on the file system and only needs to be accessible by the Domino Designer client.  You then use the existing Tools menu in the Designer client to perform the transformation.  No .nsfs to install, no code to sign etc. 

The following walk through demonstrates how this will work.

Download the XSLT Style sheet from here

Copy it to your <notesInstall>/data/xsl directory

Open the Domino Designer Client

Open the Application that contains the Domino Form to be Transformed

Form the menu choose Tools | DXL Utilities | Transformer...

This will open the DXL Transformer Dialog.  Check one of the forms in the forms list on the left.  Select the "DominoDBDXLtoXPage.xsl" stylesheet from the list on the right(This is the file you downloaded and copied into the data/xsl directory).  Leave the Send output to defaulted to "Display".  Click the "OK" button.

 

This will open the transformed XPage in the Browser (But it will not be displayed as an XPage.  You will see the following in your browser.

 

Right click on the Web Page and choose to view the page source (which is the XPage xsp code)

Select all of the code (ctrl-A) and then copy the code to the clipboard.  Close the View Source window and the web browser window.

Back in the Domino Designer, create a new XPage in the same application that the original Domino Form was transformed from.

 

Switch to the "Source" view.  Delete the Existing Code

 

Paste in the code from the Clipboard.  Hit CTLR-SHIFT-F to format the code.

 

Switch to the Design view to see the controls in design view.

 

Preview the the XPage in your default browser to test the XPage.

The results of the transformation is that a document data source referencing the current application and the selected form are added to the XPage.  A Table is created with a Label created from the field name and a control with the same name and type as from the Domino Form.  Default values are brought across for editable fields.  If it is formula based it is brought across as JavaScript comments so the original logic is retained.

All Static keywords (both values and aliases) are brought across for all the selection type fields.

If there is a control you don't need then simply select the table row in the Outline view and delete it from the right click menu.  My experience has been it is easier to delete the controls I don't need than add the individual computed fields in manually.

It's not perfect and it does not duplicate all of the form logic 100% but gets a lot closer.  I figure the less time I spend editing the more time I have for development.  Work smarter not harder.

My disclaimer (there is always a disclaimer) is that it's still a work in progress.  I will eventually put a UI on it and create the XPage XML from a form where developers can choose what they want to include, change switches etc.  But for now it is a handy tool in my toolbox.  I hope it will help save some XPage developers some time. 

PrintView Printer Friendly Version

EmailEmail Article to Friend

Reader Comments (12)

I may never have to write another line of code in my life. Great stuff.

Indeedy, "work smarter, not harder". You'll get paid the same regardless.

July 23, 2009 | Unregistered CommenterDarren Duke

Very Cool !

Thanks for sharing, Paul

July 23, 2009 | Unregistered CommenterDan

Indeed. That is H-O-T Hot!

July 23, 2009 | Unregistered Commenterjake

Great article Paul! Thanks for sharing this...

-John

July 23, 2009 | Unregistered CommenterJohn Mackey

Good stuff! Thanks

July 23, 2009 | Unregistered CommenterRoland Reddekop

Now that's a nice tip!

Thanks Paul!

July 24, 2009 | Unregistered CommenterJohn Turnbow

Excellent work! Looking forward to see more.

July 27, 2009 | Unregistered CommenterStephan H. Wissel

Very nice Paul. Good stuff.

July 29, 2009 | Unregistered CommenterJohn Palmer

Great Stuff! This has definitely giving me more time for development. Im now working smarter not harder. Thanks..

November 29, 2009 | Unregistered CommenterRazz Khan

cool, but.... fields with a "underscore" are not valid and textstyle, formula on the fields.
maybe the next version, good work.

January 4, 2010 | Unregistered Commenterroelf

Outstanding. Thanks for your work

January 8, 2010 | Unregistered CommenterCal

nice one. It saves time to those aspiring to be xpages developer

June 30, 2010 | Unregistered Commenterjta

PostPost a New Comment

Enter your information below to add a new comment.
Author Email (optional):
Author URL (optional):
Post:
 
Some HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>