> List of tutorials


Fat-Client-Development - Base-Class for reading a file with XML-structure

* For this document and all references (links) please obey the hints and regulations concerning copyright, disclaimer and trademarks.

  • The owner of this web-site (www.javascout.biz) is not responsible for the content of web-sites linked within this document or other documents of www.javascout.biz.

  • If this document or other documents of this web-site (www.javascout.biz) infringes rights of third parties and your rights are infringed or you think that rights of others are infringed, please inform the author.
    An e-mail can be sent by clicking onto the 'hungry mailbox' in the upper right corner.

Last revision of this document:
2006-05-05

This step of the tutorial deals with reading a file that contains a XML-structure.

A Base-Class is developed that reads the XML-structure within a file into a DOM-element (DOM = Document Objects Model; for detailed information please see the link under 'Credits').
This base class is later used within specialized classes to search the DOM-element like a database.

Preface:

Similar parts of this tutorial were already documented with screenshots in Base lesson 2, step 3 - Read parameters for the connection to the database.
To make this document shorter, similar steps are not described in detail - just referenced to the mentioned document.
Not to document these steps in detail is also intended as a feedback:
you should be able to understand what the actions are for and find the similarities for this project.

The code written in this tutorial is far away from being optimized.
Emphasis of this tutorial is to develop the application in small steps where the completion of each step allows the application to be run eror-free and showing the result aimed by the step.
Therefore the code is written to be understandable in favor of being optimized
.

Credits:

A tutorial for reading a XML-structure in JAVA can be found under http://java.sun.com/webservices/jaxp/dist/1.1/docs/tutorial/dom/index.html .

Prerequisites:

Preparation:

Methods for reading data out of XML-formatted structures are contained in the external Java-ARchive named 'jdom.jar'.
How this JAR can be downloaded and has to be incorporated into the 'Java Build Path' of the project is described in Base lesson 2, step 3 - Read parameters for the connection to the database > Preparation.

Please obey that the 'External JAR' must be integrated into the 'Build Path' of project 'JS_FC01' and – if you decided to code the base-classes by yourself (see JS_FC01ca – Create a project for the base-classes) - in project 'JS_Base' too.

Create the Interface JSBS_XML-Constants:

In this Interface, control-values and status-code-values for all classes handling XML-structures are defined.

An Interface is created in the following way:

Create the class JSBS_XML_Base:

This class reads the file (for a file-name passed as parameter), checks if the content of the file follows the XML-syntax and creates an element with the XML-structure according to DOM (Document Object Model).

Create the class JSBS_XML_DisplayStrings:

This class is intended to have specialized methods for processing Objects forming a GUI; particularly those of type JLabel, JText, JComboBox and JListBox and setting their properties - mainly text for Labels and ToolTipText.

For now no methods are coded (except for the constructor).
This class is introduced now that it can be incoporated into the base-frame.
Methods for this class are coded in the next step(s).

Incorporate the class JSBS_XML_DisplayStrings into the base-frame:

'Construct' the class JSBS_XML_DisplayStrings:

Next Step: