Subscribe via FeedPaul Calhoun, Jul 22, 2009 6:47:47 PM
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.
- The fields are always added in alphabetical order versus the order they appear on the Domino Form design.
- 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
- Computed fields are not brought across at all.
- There was no way to create Radio or Checkbox keyword fields dynamically
- 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
- Reorder the fields and Lables in the Table
- Add the Computed fields
- Change the controls that should be Radio Button and CheckBox controls manually
- 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 /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.
13 responses to Transforming Domino Forms into XPages via XSLT
Sujit, January 16, 2011 1:21 PM
Application of XML + XSLT to its BEST.
jta, June 29, 2010 10:40 AM
nice one. It saves time to those aspiring to be xpages developer
Cal, January 7, 2010 3:16 PM
Outstanding. Thanks for your work
roelf, January 3, 2010 9:52 AM
cool, but.... fields with a "underscore" are not valid and textstyle, formula on the fields.
maybe the next version, good work.
Razz Khan, November 29, 2009 12:54 AM
Great Stuff! This has definitely giving me more time for development. Im now working smarter not harder. Thanks..
John Palmer, July 28, 2009 6:00 PM
Very nice Paul. Good stuff.
Stephan H. Wissel, July 26, 2009 3:37 PM
Excellent work! Looking forward to see more.
John Turnbow, July 23, 2009 12:34 PM
Now that's a nice tip!
Thanks Paul!
Roland Reddekop, July 22, 2009 10:38 PM
John Mackey, July 22, 2009 10:12 PM
Great article Paul! Thanks for sharing this...
-John
jake, July 22, 2009 9:15 PM
Indeed. That is H-O-T Hot!
Dan, July 22, 2009 9:02 PM
Very Cool !
Thanks for sharing, Paul
Darren Duke, July 22, 2009 9:00 PM
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.