DCOSetup API

The DCOSetup APIs include properties and methods that you can use to create or modify the document hierarchy. Datacap saves the document hierarchy as the setup DCO file in XML format, for example, C:\Datacap\application name\dco_application name\application name.xml.

In the setup DCO file, each document, page, and field type is defined as a separate node, as shown in this sample XML code:

<?xml-stylesheet type="text/xsl" href="..\..\dco.xsl"?>
<S>
  <B type="batch_name">  1  
 
 [Variables and rules associated with this batch]

   </B>
   <D type="document_name">  2 

 [Variables and rules associated with this document]

   </D>

   [more document types]

   <P type="page_name">  3 

 [Variables and rules associated with this page]

   </P>

   [more page types]

   <F type="field_name">  4 

 [Variables and rules associated with this field]

   </F>

   [more field types]

   <DICT n="dict_name">  5 

 [Terms (words and values) in this dictionary]

   </DICT>

   [more document types

 1  Setup node for the batch

 2  Setup node for the document

 3  Setup node for the page

 4  Setup node for the field

 5  Setup node for the dictionary

When you use an API to populate the DCOSetup object with child nodes from the Setup DCO file, each node becomes a separate DCOSetupNode object.

You use the DCOSetup APIs to modify the DCOSetup object and use the DCOSetupNode APIs to modify the child DCOSetupNode objects.

Accessing the DCOSetup object and child DCOSetupNode objects

When you create a runtime DCO object (m_oDCO in this example), Datacap automatically creates a corresponding DCOSetup object and updates the setup DCO file.

TDCOLib.IDCO m_oDCO = new TDCOLib.DCOClass();
DCO object and DCOSetup object

You can use the SetupObject method to access the DCOSetup object either directly or by first obtaining an interface to the DCOSetup object:

Accessing the DCOSetup Object Directly
m_oDCO.SetupObject().AddNode(1,"NewDoc1");
Accessing the DCOSetup object through an interface
 TDCOLib.DCOSetup m_oDCOSetup = m_oDCO.SetupObject(); 
  //Obtaining an interface

m_oDCOSetup.AddNode(1,"NewDoc2"); 
  //Accessing the DCOSetup object through the interface

The DCOSetup object is initially null. You populate the DCOSetup object and the child objects in one of the following ways:

Use the ReadSetup method from an existing Setup DCO file
m_oDCO.ReadSetup("C:\\Datacap\\APT\\dco_APT\\APT.XML");
The ReadSetup method parses the XML file and creates all of the child DCOSetupNode objects, such as documents, pages, and fields, that are defined for the document hierarchy.
Use the AddNode method
m_oDCO.SetupObject().AddNode(1,"NewDoc1");
If you are creating a Setup DCO or modifying an existing Setup DCO, you can write the memory resident object hierarchy to disk by using the WriteSetup method:
 m_oDCO.WriteSetup("C:\\Datacap\\APT\\dco_APT\\APT.XML");