Browsing for Messages in your Application Library

Tony Marston - 5th January 2002
amended 10th July 2002

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

LibraryIDMessage
end of messages
USYSM_9000190001: STORE failed - see Message Frame for more details
USYSM_9000290002: STORE successful
USYSM_9000390003: No changes found - Store not executed
USYSM_9000490004: RETRIEVE failed - invalid key passed from popup
USYSM_9000590005: Nothing selected from popup
USYSM_9000690006: RETRIEVE failed - see Message Frame for more details
USYSM_9000790007: No entries were found matching this profile
USYSM_9000890008: This function has been disabled
USYSM_9000990009: This action is not valid on an empty occurrence
USYSM_9001090010: This is a database occurrence - value cannot be changed
USYSM_9001190011: This is a database occurrence - entry cannot be deleted
USYSM_9001290012: You must CLEAR the screen before attempting a RETRIEVE
USYSM_9001390013: Cannot delete - subordinate entries exist on %%$entname
USYSM_9001490014: STORE failed in form %%$instancename, status = %%$status, entity = %%$entname
USYSM_9001590015: ERASE failed - see Message Frame for more details
USYSM_9001690016: ERASE not allowed
USYSM_9001790017: Erase successful
USYSM_9001890018: Controls released - data available as default for new input
USYSM_9001990019: No help text found for %%$1
USYSM_9002090020: Entry not found

Creating an XML file

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>

Viewing an XML file

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:-

Contents of MESSAGES.XSL

<?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.

Contents of MESSAGES.HTML

<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

Amendment history:

10th July 2002 Updated for version 4 of the MSXML Parser. This involves changes to MESSAGES.XSL as follows:
  • Changed the XSL namespace clause from
    xmlns:xsl="http://www.w3.org/TR/WD-xsl" to
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform".
  • Included a namespace declaration for xmlns:USOURCE="USOURCE.DICT".
  • Inserted basic stylesheet options to set the left and right margins of the HTML output.

counter