About This Code
Brief Description:
xslt for field documentation of forms
Contributor:
Christian Gorni
Last Modified:
13 Sep 2006
OpenNTF Disclaimer
All of the program code and information presented in the OpenNTF.org Code Bin are provided "as-is", and should be used at your own risk. OpenNTF.org make no express or implied warranty about anything in the Code Bin, and OpenNTF.org will not be responsible or liable for any damage caused by the use or misuse of anything from this site. OpenNTF.org makes no guarantees about anything. Please thoroughly test all of the knowledge and code you find here before you attempt to use them in your production environment.
Code / Description
============================================
Description
============================================
This file is my little xsl learning project, I thought it is worth sharing. It creates an HTML documentation of all fields in a form. Of course you can have such a list with LotusScript too, so here are the special features:
- now forms AND subforms are supported by this single xslt
- field type (editable, computed, ..) is shown with an icon
- Indication whether field is multi value is shown
- indication of hide-when usage
- used events, subforms and shared fields
and the most interesting part:
when you place a REM line at the top of the 'default value'/'value' event of a field, the contents of the REM is added in the 'Comment' column of the HTML table.
The idea behind this is to have a documentation feature like javadoc in Lotus Notes. Of course this is just a proof of concept :-)
Please drop me a line if you have any ideas for improvement. I am no HTML pro, so I bet there are many.
I hope the comments in the xsl-file are easy to understand :-)
Have fun.
============================================
Future Enhancements
============================================
- links between fields: like "this field y is read by/ is written by field x"
- "Synopsis Framework": a common HTML-page as entry point of all form/view documentations of a database
============================================
Known Problems/Shortcomings
============================================
- none that I know of :-)
============================================
Version History
============================================
Version 3.0 (06.09.2006)
------------------------------------
- added list of used subforms
- added list of used shared fields (thx for the code to Cheryl A. Foster)
- added indicator, when field is influenced by hide-when settings
- some minor improvements
Version 2.2.1 (09.11.2004)
----------------------------------
- fixed bug posted by a user: now "REM{" AND "REM {" are recognized as comments in FormsToHTMLTable (see below)
Version 2.2 (13.08.2004)
----------------------------------
- all REM lines in a field are added to the HTML output
- new example Screenshot for "Forms to HTML" (now with legend!!!)
Version 2.1 (10.08.2004)
----------------------------------
- added "Used events" for forms
- new example Screenshot for "Forms to HTML"
Version 2.0
----------------
- Added fixed stylesheet for table layout (synopsis2.css), removed all table attributes from xsl files
- added support for views (ViewsToHTML V2.0.xsl)
- added data type column for forms
- some table/icon changes
Usage / Example
==========================
In order to use it, do the following:
==========================
1) place xsl/css files into the standard <your data directory>\xsl directory. Mine is \C:\Lotus\Notes6\Data\xsl.
2) you must change icon/css directories stored in variables in the both xsl-files (!!) according to step 1
* <xsl:variable name="CSS_Path" select="'C:\lotus\notes6\data\xsl\'"/>
* <xsl:variable name="ICON_Path" select="'C:\lotus\notes6\data\domino\icons\'"/>
3) optional: create some REM comments in 'default value'/'value' events in your form
4) in Designer: choose menu 'tools-DXL Utilities-Transformer...'
5) select xsl file for views or forms. it should be visible on the right hand side (else you can browse for
it)
6) choose one or more FORMS/VIEWS from the list on the left
7) press OK
==========================
Some Explanations
==========================
New in V3.0: Hide-When indicator. For all, who are interested, here is a little explanation how I accomplished that.
The Problem was, that the hide-when formulas and flags can NOT be found under the <field> tag. A field only has a flag for a paragraph:
<par def="...">
The Hide-When stuff is found under the paragrapjh definition for that paragraph, which unfortunately is at a complete other place in the DXL:
<pardef id="...">
So, we have to play around with XPath expressions a bit to go from one branch of the DXL to the other. I defined two variables in order to make it all more readable. It is done like this:
<xsl:variable name="paragraphnr" select="ancestor::dxl:par/attribute::def" />
<xsl:variable name="paragraphdefinition" select="preceding::dxl:pardef[attribute::id = $paragraphnr]" />
The paragraph number is a tag found as parent (or grandparent or...) of <field> (hence 'ancestor'). The definition is somewhere in front of <field> (therefore 'preceding').
Code Attachments
Comments
Posted by Markus Langer on 08/04/2004 05:16:59 AMsynopsis2.css works not with FormsToHTMLTable V2.0.xsl
hello,
the stylesheet file works not with the FormsToHTMLTable V2.0.xsl. The output file is not formatted like the screenshot above.
bye
Posted by Christian Gorni on 08/04/2004 01:43:27 PMoops, sorry too many versions on my laptop :-)
... now its the correct FormsToHTML V2.0.xsl
so just replace that file.
Thx for the comment.
Posted by Adam M Slagle on 08/06/2004 10:11:58 AMView stylesheet not working, and comments don't appear
The view xsl may be wrong as well - it isn't being styled.
Also, I can't get comments to appear. I'm using 6.02.
Other than that, this is pretty slick.
Posted by Christian Gorni on 08/10/2004 02:42:27 PMIMPORTANT: Paths !!!
Did you check the paths in the xsl files? They point to the xsl-directory/icon-directory.
- Just open them with a text editor
- Attention the paths are enclosed with " AND ' !!!
Posted by bruce lill on 08/15/2004 10:18:57 AMThe Comments aren't captured with 6.5 because of a space
With R6 the REM statesments are saved as "REM {" but in the xsl the match is on "REM{", no space after the REM. if you change the xsl to 'REM {')" everthing works. Great job.
<!-- **************************************************************************************** -->
<!-- ******************** extract REM lines recursively ********-->
<!-- **************************************************************************************** -->
<xsl:template name="getREM">
<xsl:param name="txt" select="''"/>
<xsl:if test="contains($txt, 'REM {')">
<xsl:value-of select="substring-before(substring-after($txt, 'REM {'), '}')"/>
</xsl:if>
<xsl:variable name="left" select="substring-after($txt, '}')"/>
<xsl:if test="contains($left, 'REM {')">
<br/>
<xsl:call-template name="getREM">
<xsl:with-param name="txt" select="$left"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
Posted by Cheryl A. Foster on 01/27/2006 01:48:29 PMAdded a section for shared fields in the Body Template - after the field search
<xsl:template match="dxl:body">
<xsl:for-each select="descendant::dxl:field">
.....
</xsl:for-each>
<!-- Shared Fields -->
<tr class="TableGeneralHead">
<td colspan="5" class="descColumn"> Shared Fields </td>
</tr>
<xsl:for-each select="descendant::dxl:sharedfieldref">
<xsl:sort select="@name"/>
<tr>
<!-- Field name -->
<td><xsl:value-of select="@name"/></td>
</tr>
</xsl:for-each>
</xsl:template>
Posted by Markus Koller on 04/18/2007 02:19:48 AMIcons
Looks really great!
An explanation of the icons at the bottom of the report would be nice (for printing).