PDF version of this page

Defining Fields and Rules for XML Input

XML files are readily converted into FormTrap XML format. XML files already have all fields defined, already have the concepts of master and detail and have their contents for Dates and Numeric in useful format. Conversion is quick and the process is outlined below.

This screen shows the XML Data File file (top middle) with Name and Value of the selected field (top right). Record:Field list (bottom left shows master, then in record definition order, field definition order within Record) and Path (to the XML field) and finally Rule Path for the rule that identifies this document.

If (and only if) the XML data file contains multiple documents, please specify a single rule that identifies the document being defined. Rules are exact match only, with choices for Add and Delete only. Chose a field that is unique for the document type and add a rule for it. In the tutorial, the presence of "OrderLine" identifies this as an "Order". "Order" is the top level name associated with "OrderLine".

Select a field from the XML data file that uniquely identifies this as the required document type, and press (Add Rule). The rule appears in Rule Path (bottom right) and at the top of the Record:Field list with Path as top level item for the document (/Order in the example).

To remove a Rule, highlight it in Rule Path and press (Delete).





To add master fields, select the XML field name and press New Field.

     

Field properties are entered or edited here.

Name is suggested and may be over-keyed if you do not like the XML input name.


Normalize is the named RegEx used to reformat data to the XML field.










Predefined expressions are provided in the Search and replace pull-down (and you can include your own expressions).

 

               

Data is normalized in the output XML file. The common normalizations are:

Remove leading zeroes - used for records mode raw data - removes leading spaces and zeroes - retains one zero if the field is all zero.
Remove superflous white space - used to remove leading, trailing and internal multiple spaces (leaving one internal space).
Trim numeric - used to trim spaces from numerics, including substitution of 0 if the field is empty.
Trim - trims leading and trailing spaces from the data - use for text data to avoid doing this at form design time. This is required for fields used as substitutions.



Case normalization applies to text fields and offers these choices:





If content is numeric or date please select Parser; Type.  This is the Parser type pull-down:


     


If a Date was selected, this is the Pattern pull-down for date formats:


     


Parser type Date is normally yyyy-MM-dd, however as shown, other formats are possible, and you can make up your own.



These date conventions are available for Pattern:

d one nor two digit day
dd two digit day with leading zero where required
ddd 3-character abbreviation of Day in Locale convention (eg FRI)
dddd full day (Friday)
M one or two digit month
MM two digit nonth with leading zero where required
MMM 3-character abbreviation of Month in Locale convention (eg OCT)
MMMM full month (October)
yy last two digits of year
yyyy four-digit year


Fields appear in the order added in the Records:Fields list, and alphabetically in the Documents, Data, master, Fields list.

Occasionally selecting a field in the XML view may show more than one entry in the Name Value list, as shown below. The "Content" line is always there one line only. Additional "attributes" or optional fields may show, such as CurrencyId in the example.

To define an attribute as a field, highlight it and press New Field .

Attributes are identified by the additional component /@name in XPath (/@currencyId).

Top

Defining Detail Records

To define a Detail record, highlight that record in the XML file and press New Record .

Once you have the record defined, you can define fields in exactly the same way as for master fields.

Top

Defining Detail Record Fields in Master

Occasionally, you may require detail record fields in the Master - common where Delivery Details are present in Detail Lines, are all identical and are require printing on the Report Header. The instructions that follow are exact, with loose explanations - more knowledge of XML is required to fully understand what the actions stand for.

This is the record structure, where delivery details from the first OrderLine are required in master.

Select the field in OrderLine and press New Field .

Supply Name and change Record to master (in place of the assumed detail line record name).

Prefix Xpath with xxx:XMLNameOfDetail/ where xxx is copied from the supplied first three letters. The highlight shows this where xxx is cat. This is case sensitive. This correctly locates the XML field as being within the detail line rather than elsewhere in the structure.

Suffix Xpath with [1], this takes the first detail line data.

Top