How many times have you wanted to browse through the global procs in your application library but felt restricted by the limitations of the standard dialog box within the UNIFACE development environment?
By experimenting with XML and XSL files I have created a facility which provides the following abilities:-
This particular method is a two-stage process:-
When viewed from within a web browser the contents of the XML file can be viewed in a single browser window, and can be searched using the standard Edit/Find commands available from the browser's pulldown menu. This will enable you to include the whole of the proc body in your search criteria. Provided that you follow the steps outlined below your browser view should look something like Table 1. You will notice that this starts with a table of contents with hyperlinks into the body of each proc.
Table 1 - Formatted View of XML file
Library | Module | Description |
---|---|---|
MENU | INIT_PROC | <INIT> operation |
SYSTEM_LIBRARY | ACT_BUTTONS | ACTION_BAR buttons |
SYSTEM_LIBRARY | ACTIVATE_PROC | activate an instance |
SYSTEM_LIBRARY | ADD_TO_LIST | add to associative list |
MENU | INIT_PROC | <INIT> operation |
;----------------------------------------------------------------------- ; standard initialisation proc for all external schemas ;----------------------------------------------------------------------- variables string lv_formname endvariables .... |
||
SYSTEM_LIBRARY | ACT_BUTTONS | ACTION_BAR buttons |
;----------------------------------------------------------------------- ; put labels into buttons on ACTION_BAR ;----------------------------------------------------------------------- params string pi_Action_Bar : IN endparams variables string lv_List, lv_Field endvariables .... |
||
SYSTEM_LIBRARY | ACTIVATE_PROC | activate an instance |
;----------------------------------------------------------------------- ; create and activate an instance ;----------------------------------------------------------------------- variables string s1, s2 string lv_Component, lv_Instance, lv_Properties, lv_Params numeric lv_RetStatus endvariables .... |
||
SYSTEM_LIBRARY | ADD_TO_LIST | add to associative list |
;----------------------------------------------------------------------- ; merge ADDITIONS list with ORIGINAL list ;----------------------------------------------------------------------- params string pi_additions : IN string pio_original : INOUT endparams variables string lv_string_in, lv_entry, lv_idbit, lv_valuebit endvariables .... |
||
The ability to export/import repository objects in XML format was first made available in UNIFACE 7.2.05. To export your application messages to an XML file you must perform the following:-
The contents of the XML file created by this method should look something like the following when viewed in a text editor:-
<?xml version='1.0' ?> <!-- Created by UNIFACE - (C) Compuware Corporation --> <UNIFACE release="7.2.06.33(u-stz033)" xmlengine="1.0"> <TABLE xmlns:ULIBR="ULIBR.DICT"> <OCC> <ULIBR:ULIBRARY>MENU</ULIBR:ULIBRARY> <ULIBR:UDESCR>MENU system</ULIBR:UDESCR> <ULIBR:UTIMESTAMP>1999-07-09T08:06:50</ULIBR:UTIMESTAMP> </OCC> <OCC> <ULIBR:ULIBRARY>SYSTEM_LIBRARY</ULIBR:ULIBRARY> <ULIBR:UTIMESTAMP>2001-02-12T17:47:33</ULIBR:UTIMESTAMP> </OCC> </TABLE> <TABLE xmlns:USOURCE="USOURCE.DICT"> <OCC> <USOURCE:UTIMESTAMP>2001-04-09T08:50:41</USOURCE:UTIMESTAMP> <USOURCE:USUB>P</USOURCE:USUB> <USOURCE:UVAR>MENU</USOURCE:UVAR> <USOURCE:ULABEL>INIT_PROC</USOURCE:ULABEL> <USOURCE:ULAN>P</USOURCE:ULAN> <USOURCE:UDESCR><INIT> operation</USOURCE:UDESCR> <USOURCE:UCONFIRM>F</USOURCE:UCONFIRM> <USOURCE:UTEXT>;----------------------------------------------------------------------- ; standard initialisation proc for all external schemas ;----------------------------------------------------------------------- variables string lv_formname endvariables .... ;</USOURCE:UTEXT> </OCC> <OCC> <USOURCE:UTIMESTAMP>2002-06-20T13:50:03</USOURCE:UTIMESTAMP> <USOURCE:USUB>P</USOURCE:USUB> <USOURCE:UVAR>SYSTEM_LIBRARY</USOURCE:UVAR> <USOURCE:ULABEL>ACTIVATE_PROC</USOURCE:ULABEL> <USOURCE:ULAN>P</USOURCE:ULAN> <USOURCE:UDESCR>activate an instance</USOURCE:UDESCR> <USOURCE:UCONFIRM>F</USOURCE:UCONFIRM> <USOURCE:UTEXT>;----------------------------------------------------------------------- ; create and activate an instance ;----------------------------------------------------------------------- variables string s1, s2 string lv_Component, lv_Instance, lv_Properties, lv_Params numeric lv_RetStatus endvariables .... ;</USOURCE:UTEXT> </OCC> </TABLE> </UNIFACE>
If you simply double-click on this XML file it is possible for it to appear in your browser, but instead of being formatted as shown in Table 1 it will simply look like the raw XML data but indented and colour coded. In order for the raw XML data to be formatted into a more readable format what you need are two additional files which can be created using the sample code shown below. These files are:-
<?xml version='1.0'?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:USOURCE="USOURCE.DICT"> <xsl:template match="/"> <html> <head> <STYLE type="text/css"> <![CDATA[ <!-- BODY { margin-left: 5%; margin-right: 5%; } TR.contents { background-color: #ccffff; } TR.hdg { background-color: #99ff99; } TR.code { background-color: #dddddd; } --> ]]> </STYLE> </head> <body> <table border="1" cellpadding="6px"> <caption style="font-size:150%;"><b>Global Procs</b></caption> <tr><th>Library</th><th>Module</th><th>Description</th></tr> <xsl:apply-templates select="/UNIFACE/TABLE/OCC[USOURCE:UVAR]" mode="toc"> <xsl:sort select="USOURCE:UVAR"/> <xsl:sort select="USOURCE:ULABEL"/> </xsl:apply-templates> </table> <br /> <table border="1" cellpadding="6px" width="100%"> <xsl:apply-templates select="/UNIFACE/TABLE/OCC[USOURCE:UVAR]"> <xsl:sort select="USOURCE:UVAR"/> <xsl:sort select="USOURCE:ULABEL"/> </xsl:apply-templates> </table> </body> </html> </xsl:template> <xsl:template match="/UNIFACE/TABLE/OCC" mode="toc"> <tr class="contents"> <td><xsl:value-of select="USOURCE:UVAR"/></td> <td><a href="#{USOURCE:UVAR}:{USOURCE:ULABEL}"><xsl:value-of select="USOURCE:ULABEL"/></a></td> <td><xsl:value-of select="USOURCE:UDESCR"/></td> </tr> <xsl:variable name="position" select="position()" /> <xsl:variable name="next" select="/UNIFACE/TABLE/OCC[$position+1]/USOURCE:UVAR" /> <xsl:if test="USOURCE:UVAR != $next"> <tr><td colspan="3"> </td></tr> </xsl:if> </xsl:template> <xsl:template match="UNIFACE/TABLE/OCC"> <tr class="hdg"> <td><xsl:value-of select="USOURCE:UVAR"/></td> <td><a name="{USOURCE:UVAR}:{USOURCE:ULABEL}"><xsl:value-of select="USOURCE:ULABEL"/></a></td> <td><xsl:value-of select="USOURCE:UDESCR"/></td> </tr> <tr class="code"> <td colspan="3"><pre><xsl:value-of select="USOURCE:UTEXT"/></pre></td> </tr> <tr><td colspan="3"> </td></tr> </xsl:template> </xsl:stylesheet>
This basically contains instructions to create an HTML document using data obtained from an XML file. I shall not bother to explain what the individual commands mean as that is better done in an XML/XSL tutorial such as can be found at www.w3schools.com.
<html> <body> <script language="javascript"> // Load XML var xml = new ActiveXObject("Microsoft.XMLDOM") xml.async = false xml.load("globalprocs.xml") // Load the XSL var xsl = new ActiveXObject("Microsoft.XMLDOM") xsl.async = false xsl.load("globalprocs.xsl") // Transform document.write(xml.transformNode(xsl)) </script> </body> </html>
When you double-click on GLOBALPROCS.HTML this will activate your browser. This will then transform the contents of GLOBALPROCS.XML into a new document using the instructions in GLOBALPROCS.XSL. This new document should look something like that shown in Table 1. If it does not then you are probably running a version of Internet Explorer with an out-of-date version of the XML Parser. You need at least version 4.0 which can be obtained from Microsoft at http://msdn.microsoft.com/xml/default.asp. The latest release (27 March 2002) is v4.0 SP1.
Tony Marston
15th July 2002
mailto:tony@tonymarston.net
mailto:TonyMarston@hotmail.com
http://www.tonymarston.net