Kofax DOKuStar Validation User Manual

Page 20

Advertising
background image

DOKuStar Validation Programming Manual

Page

16

Let us go through this step by step:

Private Sub Form_Load()
Dim MyApp As New DOKuStarDataset.Application '* declare dataset part of
DOKuStarValidation

'* make sure no project is open
If Not MyApp.Project Is Nothing Then
MyApp.Project.Close
End If

'* create the Project and fill the schema
MyApp.CreateProject

As before, we create an instance of

DOKuStarValidationApplication

. The next line is just some safe

programming: If the

app

variable has already a

Project

object assigned, close it first, before creating a new one.

Next, we call a subroutine that shall fill the schema. So step right down to the schema object and hand it over to the
subroutine:

fillSchema MyApp.Project.DataSet.schema

Now for the subroutine itself:

'* first, define the DocumentTypes
Set docTypeLetter = schema.DocumentTypes.Add("Letter") ' add the "Letter" document type
docTypeLetter.FieldTypes.Add "TextField", "Sender" ' add the "Sender" field as TextField

The

DataSchema

object has got a

DocumentTypes

collection assigned to it. Collections appear frequently in

the DOKuStar Validation object list; they have got all the methods necessary to access elements, cycle through them,
etc. See the reference for a complete description.

Here, we add a new document type named

Letter

. The

Add

method delivers a

DocumentType

object. This

DocumentType

object has a

FieldTypes

collection, where we add a new

FieldType

. This

Add

method

takes two parameters: First, the field class (which is

TextField

or

TableField

), second, the name of the new

field.

Set docTypeInvoice = schema.DocumentTypes.Add("Invoice") ' add the "Invoice" document type
Set fld = docTypeInvoice.FieldTypes.Add("TextField", "TotalAmount") ' add a TextField
Set fld = docTypeInvoice.FieldTypes.Add("TextField", "InvoiceDate") ' add a TextField
Set fld = docTypeInvoice.FieldTypes.Add("TableField", "Details") ' add a TableField
fld.FieldTypes.Add "TextField", "Quantity" ' add a column
fld.FieldTypes.Add "TextField", "SinglePrice" ' add a column
fld.FieldTypes.Add "TextField", "TotalPrice" ' add a column

We do the same for the

Invoice

document. We add two

TextFields

and a

TableField

. This time, we store

the resulting

FieldType

object in a variable

fld

(which is obviously redundant for the two text fields, as it is

overwritten immediately), but we need to keep this object when adding the table field: To add the columns, use the

FieldTypes

collection of the field itself, which holds a collection of sub-fields of the field. These sub-fields denote

the columns of the table.

After adding all the document types, we need to build the hierarchical structure, i.e. fill the

DocumentModel

.

The

DocumentModel

is an object assigned to the

Schema

. It has got a

DocumentDescriptors

collection,

whose

Add

method takes a

DocumentType

object as a parameter. We add our top level

DocumentType

object here (

Letter

); if we had no hierarchical structure, we would add all document types here.

'* second, define the DocumentModel
Set docDescLetter = schema.DocumentModel.DocumentDescriptors.Add(docTypeLetter)

The

Add

method returns a

DocumentDescriptor

object; this object in turn has a

DocumentDescriptors

collection, where we can add our subdocuments:

Advertising