Using DAL XML Functions

There are two scenarios in which you would use DAL XML functions:

Scenario 1

A Documaker program, such as GenData, loads an XML document and extracts the XML tree at the transaction level using the XMLFileExtract rule. This rule creates a list type DAL variable with a default name of %extract and pushes it onto the DAL stack.

Then you can call other XML functions in a DAL script to access the XML tree and extract XML data.

Here are examples of the form set and section rules you would add and a DAL script that would call the XML functions.

Add this in the AFGJOB.JDT file:

;XMLFileExtract;2;File=.\deflib\test.xml

The rule loads the XML file and creates a list type DAL variable to pass the XML tree to the XML API function.

Here is an example of the DAL script:

%listH=XMLFind(%extract, "Forms", "Form");
#rc=XMLFirst(%listH);
if #rc=0
return("Failed to XMLFirst");
end
aStr=XMLGetCurText(%listH);
return(aStr);

%listH denotes a list type DAL variable. #rc denotes an integer type DAL variable. aStr denotes a string type DAL variable.

Scenario 2

You can also load the XML document and create the XML tree at a specific section field by calling the LoadXMLList rule from a DAL script. You must set the calling procedure as shown in Scenario 1.

Here is an example of DAL script file:

%xListH=LoadXMLList("test.xml");
%listH=XMLFind(%xListH,"Forms","Form/@*");
aStr=XMLNthAttrValue(%listH,2);
#rc=DestroyList(%xListH);
return(aStr);