One of the problems I have encountered when using messages from an application library is finding out if the message I want already exists or not, and if it does what is its identification? Unfortunately the UNIFACE form for maintaining messages does not give you the ability to search on the contents of any message text, just the message name or description.
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 message text in your search criteria. Provided that you follow the steps outlined below your browser view should look something like Table 1.
Table 1 - Formatted View of XML file
Library | ID | Message |
---|---|---|
end of messages | ||
USYS | M_90001 | 90001: STORE failed - see Message Frame for more details |
USYS | M_90002 | 90002: STORE successful |
USYS | M_90003 | 90003: No changes found - Store not executed |
USYS | M_90004 | 90004: RETRIEVE failed - invalid key passed from popup |
USYS | M_90005 | 90005: Nothing selected from popup |
USYS | M_90006 | 90006: RETRIEVE failed - see Message Frame for more details |
USYS | M_90007 | 90007: No entries were found matching this profile |
USYS | M_90008 | 90008: This function has been disabled |
USYS | M_90009 | 90009: This action is not valid on an empty occurrence |
USYS | M_90010 | 90010: This is a database occurrence - value cannot be changed |
USYS | M_90011 | 90011: This is a database occurrence - entry cannot be deleted |
USYS | M_90012 | 90012: You must CLEAR the screen before attempting a RETRIEVE |
USYS | M_90013 | 90013: Cannot delete - subordinate entries exist on %%$entname |
USYS | M_90014 | 90014: STORE failed in form %%$instancename, status = %%$status, entity = %%$entname |
USYS | M_90015 | 90015: ERASE failed - see Message Frame for more details |
USYS | M_90016 | 90016: ERASE not allowed |
USYS | M_90017 | 90017: Erase successful |
USYS | M_90018 | 90018: Controls released - data available as default for new input |
USYS | M_90019 | 90019: No help text found for %%$1 |
USYS | M_90020 | 90020: Entry not found |
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.2(u-s602r1l)" xmlengine="1.0"> <TABLE xmlns:USOURCE="USOURCE.DICT"> <OCC> <USOURCE:UTIMESTAMP>1999-06-19T19:02:53</USOURCE:UTIMESTAMP> <USOURCE:USUB>M</USOURCE:USUB> <USOURCE:UVAR>USYS</USOURCE:UVAR> <USOURCE:ULABEL>M_90001</USOURCE:ULABEL> <USOURCE:ULAN>USA</USOURCE:ULAN> <USOURCE:MSGTYPE>M</USOURCE:MSGTYPE> <USOURCE:UDESCR>STORE</USOURCE:UDESCR> <USOURCE:UCONFIRM>F</USOURCE:UCONFIRM> <USOURCE:UAUDIO>0</USOURCE:UAUDIO> <USOURCE:UTEXT>90001: STORE failed - see Message Frame for more details</USOURCE:UTEXT> </OCC> <OCC> <USOURCE:UTIMESTAMP>1999-06-19T19:07:31</USOURCE:UTIMESTAMP> <USOURCE:USUB>M</USOURCE:USUB> <USOURCE:UVAR>USYS</USOURCE:UVAR> <USOURCE:ULABEL>M_90002</USOURCE:ULABEL> <USOURCE:ULAN>USA</USOURCE:ULAN> <USOURCE:MSGTYPE>M</USOURCE:MSGTYPE> <USOURCE:UDESCR>STORE</USOURCE:UDESCR> <USOURCE:UCONFIRM>F</USOURCE:UCONFIRM> <USOURCE:UAUDIO>0</USOURCE:UAUDIO> <USOURCE:UTEXT>90002: STORE successful</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%; } --> ]]> </STYLE> </head> <body> <table border="1"> <thead> <tr><th>Library</th><th>ID</th><th>Message</th></tr> </thead> <tfoot> <tr><th colspan="3">end of messages</th></tr> </tfoot> <xsl:apply-templates select="UNIFACE/TABLE/OCC[USOURCE:UVAR]"/> </table> </body> </html> </xsl:template> <xsl:template match="UNIFACE/TABLE/OCC[USOURCE:UVAR]"> <tr> <td><xsl:value-of select="USOURCE:UVAR"/></td> <td><xsl:value-of select="USOURCE:ULABEL"/></td> <td><xsl:value-of select="USOURCE:UTEXT"/></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("messages.xml") // Load the XSL var xsl = new ActiveXObject("Microsoft.XMLDOM") xsl.async = false xsl.load("messages.xsl") // Transform document.write(xml.transformNode(xsl)) </script> </body> </html>
When you double-click on MESSAGES.HTML this will activate your browser. This will then transform the contents of MESSAGES.XML into a new document using the instructions in MESSAGES.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. NOTE: this link is now dead, but MSXML6 (dated 7th December 2006) can be obtained from https://msdn.microsoft.com/en-us/data/ff683553.
Tony Marston
5th January 2002
mailto:tony@tonymarston.net
mailto:TonyMarston@hotmail.com
http://www.tonymarston.net
10th July 2002 | Updated for version 4 of the MSXML Parser. This involves changes to MESSAGES.XSL as follows:
|