General
RB Manager
RB Reporter

 

RBReporter Scan XML Configuration File

Introduction

The configuration file for RBReporter scans is a text file stored in XML. The design on the format for this configuration file was kept simple and so the general application of the scanner is not meant for complicated analysis. The design works around three types of rules: Directory Rules, File Rules, and Parse Rules. Each of these will be explained below. First, here is an example file for reference. This file is the configuration file used to scan the resource bundle associated with RBManager.

Sample Scan File (rbmanager_scan.xml)

<?xml version="1.0" ?>
<RBFILESCANNER NAME="RBManager Scanner" FILENAME="rbmanager_scanner.xml">
	<FILERULES>
		<!--  FileRules can have attributes starts_with, ends_with, and contains -->
		<FILERULE NAME="Java File" ENDS_WITH=".java" />
		<FILERULE NAME="XSL File" ENDS_WITH=".xsl" />
	</FILERULES>
	<PARSERULES>
		<!--  ParseRules can have attributes follows and precedes --> 
		<PARSERULE NAME="Java static resource" FOLLOWS="Resources.getTranslation(&quot;" PRECEDES="&quot;" /> 
	</PARSERULES>
	<SCAN>
		<DIRECTORY LOCATION="\C:\Development\RBManager\Source" RECURSE_DIRECTORIES="true"> 
			<RULES>
				<APPLYFILERULE NAME="Java File">
					<APPLYPARSERULE NAME="Java static resource" />
				</APPLYFILERULE>
			</RULES>
		</DIRECTORY>
	</SCAN>
</RBFILESCANNER>
        

Details

The root element of the XML file is named 'RBFILESCANNER'. This root element has two optional attributes for naming the scan file in a human readable manner and specifying the file name. These attributes are for the developers reference; they mean nothing to RBReporter. Beneath the root element are three required elements 'FILERULES', 'PARSERULES' and 'SCAN'.

Beneath the FILERULES element are found FILERULE elements. Any number of these rules can be specified, though each must have a unique name as specified in the element's NAME attribute. Along with this name attribute, the attributes STARTS_WITH, ENDS_WITH, and CONTAINS may be optionally specified. These are the rules applied to each file in a directory to determine whether or not they will be scanned. The attribute rules are applied to the file names of each file in the directory and if each is found to be true, that file is evaluated against the parse rules.

Beneath the PARSERULES element are found PARSERULE elements. Any number of these rules can be specified, though each must have a uniques name as specifiedn in the element's NAME attrinute. Along with this name attribute, the attributes FOLLOWS and PRECEDES may optionally be specified. These are the rules applied to each line of text in a selected file to determine if that line of text contains one or more resource keys.

Beneath the SCAN element are found DIRECTORY elements. Any number of these elements can be specified. The required LOCATION attribute specifies in a machine dependent manner the location of a directory for which the files are to be scanned for resource bundles. An optional RECURSE_DIRECTORIES attribute may be specified. If the value of this attribute is set to 'true', then all directories beneath the directory specified are also scanned.

Beneath each DIRECTORY element, exactly one RULES elements can be specified.Beneath this element, any number of APPLY FILE RULE elements may be specified. The required NAME attribute specifies which of the file rules defined previously are to be applied. Beneath these element any number of APPLYPARSERULE elements may be specified. The required NAME attribute specifies which of the parse rules defined previously are to be applied to the files accepted by the parent file rule.

The Example File Explained

Given the details of the file structure, we can now examine how the example file specifies which files to scan, and then how it specifies how to find the resource keys contained in those files.

RBReporter first begins by going through each of the directories specified. In the example file case, there is only one directory. It then goes through each of the files contained in that directory and its subdirectories looking for files that pass the 'Java File' file test. The 'Java File' test simply checks the file name to see if it ends in the extension '.java'. If the file has such an extension the parse rule 'Java static resource' is applied to every line of text within that file.

Thus if the following file, named Sample.java, were to be found in the directory. The two resource keys 'Hello' and 'World' would be found.

public class Sample {
	public static void main(String args[]) {
		System.out.println(Resources.getTranslation("Hello") + " " + Resources.getTranslation("World"));
	}
}
Copyright 2000-2001 International Business Machines, All Rights Reserved