> Expat4D Home > Documentation

The Demo Database

The demo database is used to test every aspect of Expat4D's functionality and show some practical demonstrations of XML at work. The application contains one dialog window, Expat4D Workshop, which allows you to change the parser settings so that different parts of Expat4D are tested.

The database requires 4D Write 6.7.x, ObjectTools and a debugging aid of your choice, e.g. DCon for 4D or DebugWindow (other can be easily plumbed in if you don't like either of these). A demo version of each plug-in is provided with the demonstration database, although if you wish to use DCon for 4D or ObjectTools in the interpreted version, you should buy yourself a licence. You can get away without having DCon, but ObjectTools 1.5.x is an absolute must for the xmlObj module.

The screen-shot below shows the first page of the Expat4D Workshop. It is through this interface that we try to test all aspects of the Expat4D plug-in. Because the xmlObject functionality is difficult see the results of, we have created a hierarchical list representation to try and give you an idea about what's going on.

Parser Handlers

The workshop dialog uses just one set of handler routines for all the different parsing options. These handlers simply decide which options you can switched on the in the workshop setup page, and run those options accordingly.

The handler routines have the following method names:

  • handler_ElementStart
  • handler_ElementEnd
  • handler_CDATA
  • handler_Comment
  • handler_Default
  • handler_NamespaceDecl
  • handler_NotationDecl
  • handler_UnparsedEntityDecl
  • handler_NotStandalone

These handler routines contain the code which is executed when the parser finds the different elements in the XML document. If you look at the handler routines themselves you see that they contain the different calls depending on what output you choose in the first page of the set-up window.

Parsing a Document

The parser handlers are set up when the method "ws_Parse" is called. This is called from the "Parse" button the form and sets up the parser and the various handlers depending on the options you choose in this dialog. This routine gives a pretty well a full demonstration of all the Expat4D features.

In order to parse a document, you must have something to Parse. The demo allows you to either enter an XML document straight into the "Sample XML" page of the workshop, open a documuent into the "Sample XML" page or open a document directly from a file. Because the "Sample XML" page is just a 4D Write area with all the menus and toolbars switched off, you can easily save your sample XML by hitting Command-S (Mac) / Control-S (Win) to get the standard 4D Write "Save As..." dialog. Remember that you need to save the file as a TEXT file, not a 4D Write document if you want to open it again.

Below is a screenshot of the "Sample XML" page of the Workshop with a sample XML document loaded.

Parse Results

There are currently three output settings for the demo parser. You can output the result to the 4D Write area, a hierarchical list, or an xmlObj.

4D Write Output

The 4D Write output shows a simple example of formatting XML in a 4D Write Area. In this case, we're simply reformatting the input XML so that it looks more attractive, but also so that the output shows which handler was used for each part of the output. This has been done by colour coding the output. Also, CDATA is displayed using the Geneva font, whereas all the other XML is output in Courier. Below is a table showing which colours and fonts are used for which types of data and also where you can find the method which sets the font, size and colour so that you can modify them.

Handler Font Settings Method
Elements Red, Courier, 10 points ws_4DW_StartTag, ws_4DW_EndTag
CDATA Black, Geneva, 9 points ws_4DW_CDATA
Comment Blue, Courier, 10 points ws_4DW_Comment
Default Violet, Courier, 10 points ws_4DW_Default
Processing Instruction Green, Courier, 10 points ws_4DW_ProcessingInstruction

Below is a screen-shot of the "4D Write Result" after parsing a document with the 4D Write output switched on.

Hierarchical List Output

Choosing this feature shows how you can create a hierarchical list of all the elements in a document using Expat4D. The hierarchical list contains a sublist for each element found in the document. The CDATA is simply wrapped at 80 characters and no special word wrapping takes place, so it may look a little odd. This is simply for demonstration purposes and not something you would expect to see in a finished application.

A more powerful solution would be to use a customised outline list in conjunction with a 4D Write area and use xmlObjects to reference between the hierarchical list and the content in the document.

The screen-shot below shows the "Hierarchical List Result" page of the Workshop showing a document which has been converted to a hierarchical list.

xmlObj Output

The xmlObj module creates groups of objects based on XML document content and allow developers to create XML documents using simple commands and without having to insert XML into their code. Used in conjunction with Expat4D, xmlObj allows developers to convert existing XML documents into xmlObjects, but with xmlObjects there's nothing much to see from a user perspective.

In view of this and to try and give developers an idea of what the xmlObj module does, we have added a couple of additional debug features to try and give an idea about what's going on. Also, there's a hierarchical list representation on the xmlObj page of the Workshop. The hierarchical list shows the structure of the objects.

Workshop xmlObj Page

Most of the list items in the list represent individual node objects of the xmlObject. By selecting an object in the list, you see the xmlObject Properties in the middle of the form.

Clicking the "Convert xmlObject to Output XML" button converts the xmlObject to an XML file and displays it in the 4D Write area on the right hand side of the form.

  Expat4D Logo

Developer Documentation

Creating Parsers, Destroying Parsers, Parsing Text

Configuring Handler Methods

Position and Error Reporting Functions

Miscellaneous Functions

Output Buffer Functions

Error Codes


> Expat4D Home > Documentation

Last Modified: 19th April 2001 at 11:11 PM