<?xml version="1.0" standalone="no"?>

<!--
* 
*
*  ProLinga-Validate
*
*  Copyright (C) 2002-2008 Xobas Software.
*  All rights reserved.
*  
*  This file is part of ProLinga-Validate.
*
*  ProLinga-Validate is free software: you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation, either version 3 of the License, or
*  (at your option) any later version.
*
*  ProLinga-Validate is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with ProLinga-Validate.  If not, see <http://www.gnu.org/licenses/>.
*
*  More information is available at the following addresses:
*
*  Website     : http://www.prolinga.org
*
*  Email       : prolinga-list@prolinga.org
*
*
-->

<!DOCTYPE article PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
    "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [

<!ENTITY version SYSTEM "version.txt" >
<!ENTITY prolinga-validate-API  SYSTEM "prolinga-validate-API.xml" >
<!ENTITY prolinga-validate-userguide  SYSTEM "prolinga-validate-userguide.xml" >
<!ENTITY fdl  SYSTEM "fdl.xml" >
<!ENTITY PRODUCT "prolinga-validate" >
<!ENTITY xobas '<emphasis><ulink url="http://www.xobas.com">Xobas Software</ulink></emphasis>'>

]>

<book id="prolinga-validate" lang="en">
  <bookinfo>
    <title>ProLinga-Validate Project</title>
    <releaseinfo>Release: &PRODUCT;-&version; - March 21, 2008</releaseinfo>
    <authorgroup>
      <author>
	<firstname>Bas</firstname>
	<surname>Driessen</surname>
	<affiliation>
          <orgname>&xobas;</orgname>
	    <address><email>bas.driessen@xobas.com</email></address>
	</affiliation>
	<contrib>Original author and current maintainer.</contrib>
      </author>
    </authorgroup>

    <copyright>
      <year>2002-2008</year>
      <holder>The ProLinga Team</holder>
    </copyright>

    <legalnotice>
      <para>Permission is granted to copy, distribute and/or modify this document
      under the terms of the GNU Free Documentation License, Version 1.2
      or any later version published by the Free Software Foundation;
      with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
      A copy of the license is included in the section entitled
      <ulink type="http"
      url="gfdl.html">"GNU Free Documentation License"</ulink>.</para>
    </legalnotice>

    <abstract>
      <para>This document describes the ProLinga-Validate Project, how to
      build the software components and documents the API reference of the 
      prolinga-validate library.</para>
    </abstract>
  </bookinfo>

  <chapter id="prolinga-validate-product-info">
    <title>ProLinga-Validate Project</title>

    <para>ProLinga-Validate is a tool that parses, validates and transforms ProLinga 4GL logic into 
    an XML document. This result XML document, called a RunControl, is 
    used at run-time by the ProLinga-Run binaries. It can further validate the physical presence of Objects,
    there where Objects are used as member Objects. For instance, if a record contains 
    a Data Dictionary called <parameter>order_no</parameter>, ProLinga-Validate can check if
    this Data Dictionary exists in a specified application Repository.</para>

    <para>ProLinga-Validate works according the Request-Response mechanism. A request can be 
    for instance to validate 4GL Logic called "Main". ProLinga-Validate will send out a 
    request to get the logic from the ProLinga-Repository, transforms it into an XML document, 
    validates the data references, writes the transformed results back as a response to 
    the remote repository and returns a response to the caller.</para>

    <para>ProLinga-Validate can be configured as a Web Service (daemon) on the machine. 
    A sophisticated SOAP layer on top controls the flow and processing of incoming and 
    outgoing requests/responses over the TCP/IP network. Using this concept, programs 
    can run locally on a machine while accessing a remote validate engine centrally 
    located in an intranet environment or anywhere in the world via the internet.
    </para>

    <para>Main purpose for the creation of this project, is to provide an
    easy way to transform user readable 4GL code into XML documents that can be processed
    by the interpreter at run-time and to provide presence checks of member Objects.
    The current implementation is specifically written for the ProLinga 4GL logic and 
    ProLinga environment. Therefore it can not directly be used in other non-ProLinga related
    projects at the moment, however the concept and portions of code can maybe help out
    there. Future releases maybe more configurable using language and grammer documents
    etc so make it a 4GL language independent tool.
    </para>

    <para>ProLinga-Validate has been built and tested on various popular GNU/Linux platforms as
    RedHat Fedora, Mandriva Linux,
    Debian, openSUSE and Ubuntu. Since 
    all code is written
    in C++, it can be ported to all modern UNIX systems, Linux variants
    as well as MS-Windows and Mac O/S platforms.</para>

    <sect1 id="prolinga-validate-transformation">
      <title>Transformation</title>

      <para>The 4GL logic produced by the developer-user, needs to be transformed to an 
      XML format which can be used by the interpreter at runtime.  These documents contain 
      information about the logic commands as well about the program flow. The validate 
      rules and formats are explained further on this page.</para>

      <para>The validate output documents have the following format:</para>

<programlisting><![CDATA[
<?xml version="1.0"?>
<ProLinga>
  <Runner Version="1.0">
    <Statements>
      <Statement SequenceNo="]]><parameter>seqno</parameter><![CDATA[" NextTrue="]]><parameter>nextstep_if_true</parameter><![CDATA[" NextFalse="]]><parameter>nextstep_if_false</parameter><![CDATA[" Command="]]><parameter>cmdno</parameter><![CDATA[" LogicLineNo="]]><parameter>lineno_4GL</parameter><![CDATA[">
        <Arguments>
          <Argument>argument</Argument>
          . . .
          . . .
        </Arguments>
      </Statement>
      . . .
      . . .
    </Statements>
  </Runner>
</ProLinga>
]]></programlisting>

<para>Example:</para>

<programlisting><![CDATA[
<?xml version="1.0"?>
<ProLinga>
  <Runner Version="1.0">
    <Statements>
      <Statement SequenceNo="1" NextTrue="2" NextFalse="2" Command="2" LogicLineNo="1">
        <Arguments>
          <Argument>TITLE</Argument>
          <Argument>"Variable -  untitled"</Argument>
        </Arguments>
      </Statement>
      <Statement SequenceNo="2" NextTrue="3" NextFalse="3" Command="3" LogicLineNo="2">
        <Arguments>
          <Argument>"Created new variable."</Argument>
        </Arguments>
      </Statement>
      <Statement SequenceNo="3" NextTrue="4" NextFalse="4" Command="4" LogicLineNo="3">
        <Arguments>
          <Argument>Record</Argument>
          <Argument>Variable.Variable</Argument>
        </Arguments>
      </Statement>
      <Statement SequenceNo="4" NextTrue="5" NextFalse="5" Command="5" LogicLineNo="4">
        <Arguments>
          <Argument>F-EditCode.Variable</Argument>
          <Argument>=</Argument>
          <Argument>P-EditCode(1)</Argument>
        </Arguments>
      </Statement>
      <Statement SequenceNo="5" NextTrue="0" NextFalse="0" Command="8" LogicLineNo="5">
        <Arguments>
          <Argument>ALL</Argument>
        </Arguments>
      </Statement>
    </Statements>
  </Runner>
</ProLinga>
]]></programlisting>

<para>This document is transformed from the following 4GL logic.</para>

<programlisting>
SCREEN TITLE "Variable - untitled"
MESSAGE "Created new variable."
CLEAR RECORD Variable.Variable
LET F-EditCode.Variable = P-EditCode(1)
DISPLAY ALL
</programlisting>


    </sect1>

    <sect1 id="prolinga-validate-validation">
      <title>Validation</title>

      <para>When the 4GL logic has been transformed into an XML document, syntax checking 
      and validation will be performed. The grammar and syntax rules of the 4GL logic are 
      outlined in a language validation file. Every 4GL logic command has an entry is this 
      file.</para>

      <para> The folowing example describes the syntax of the 4GL logic command "LET".</para>


<programlisting><![CDATA[
. . .
. . .
  <!-- Logic Command 5 : LET -->
  <LogicCommand Command="5">
    <MinArguments>3</MinArguments>
    <MaxArguments>999</MaxArguments>
    <Arguments>
      <Argument Step="1">
        <ArgumentStep Path="1" Style="SingleDataReferenceWrite" NextStep="2"/>
      </Argument>
      <Argument Step="2">
        <ArgumentStep Path="1" Style="Static" Value="=" NextStep="3"/>
      </Argument>
      <Argument Step="3">
        <ArgumentStep Path="1" Style="Static" Value="CALL" NextStep="10" />
        <ArgumentStep Path="2" Style="Numeric" NextStep="20" LastStep="True"/>
        <ArgumentStep Path="3" Style="SingleDataReference" NextStep="20" LastStep="True"/>
        <ArgumentStep Path="4" Style="String" NextStep="20" LastStep="True"/>
        <ArgumentStep Path="5" Style="MathFunction" NextStep="31" LastStep="True"/>
      </Argument>
                                                                                                                                        
      <!-- Logic Call -->
      <Argument Step="10">
        <ArgumentStep Path="1" Style="ObjectNameLogic" NextStep="11" LastStep="True"/>
        <ArgumentStep Path="2" Style="SingleDataReference"  NextStep="11" LastStep="True" />
      </Argument>
      <Argument Step="11">
        <ArgumentStep Path="1" Style="Numeric" NextStep="11" LastStep="True" />
        <ArgumentStep Path="2" Style="SingleDataReference"  NextStep="11" LastStep="True" />
        <ArgumentStep Path="3" Style="String"  NextStep="11" LastStep="True" />
        <ArgumentStep Path="4" Style="Static" Value="RETURNING" NextStep="12" LastStep="False" />
      </Argument>
      <Argument Step="12">
        <ArgumentStep Path="1" Style="SingleDataReferenceWrite"  NextStep="12" LastStep="True" />
      </Argument>
                                                                                                                                        
      <!-- Calculation/Concatenation -->
      <Argument Step="20">
        <ArgumentStep Path="1" Style="MathOperator" NextStep="30" />
        <ArgumentStep Path="2" Style="Numeric" NextStep="40" LastStep="True" />
        <ArgumentStep Path="3" Style="SingleDataReference"  NextStep="40" LastStep="True" />
        <ArgumentStep Path="4" Style="String"  NextStep="40" LastStep="True" />
      </Argument>

      <!-- Calculation -->
      <Argument Step="30">
        <ArgumentStep Path="1" Style="Numeric" NextStep="31" LastStep="True"/>
        <ArgumentStep Path="2" Style="SingleDataReference"  NextStep="31" LastStep="True" />
        <ArgumentStep Path="3" Style="MathFunction"  NextStep="31" LastStep="True" />
      </Argument>
      <Argument Step="31">
        <ArgumentStep Path="1" Style="MathOperator" NextStep="30" />
      </Argument>
                                                                                                                                        
      <!-- Concatenation -->
      <Argument Step="40">
        <ArgumentStep Path="1" Style="Numeric" NextStep="40" LastStep="True" />
        <ArgumentStep Path="2" Style="SingleDataReference"  NextStep="40" LastStep="True" />
        <ArgumentStep Path="3" Style="String"  NextStep="40" LastStep="True" />
      </Argument>
                                                                                                                                        
    </Arguments>
  </LogicCommand>
. . .
. . .
]]></programlisting>

      <para>The first step is to check if the number of arguments is within the limit of 
      number of expected arguments. Next the arguments will be processed one by one and 
      tried to be matched with a path entry starting with 1. If the argument does not match 
      a path entry, the number will be raised and will be matched against the next path 
      entry until all arguments are processed. As soon as a path entry is matched, the 
      argument will be validated in case it is a data reference where the value needs 
      to be read from the Repository. To indicate that arguments can be used more than 
      once, the setting NextStep can be used to point back to the first repeating 
      argument. The setting LastStep indicate if the argument can be the last one.</para> 

      <para>If anything goes wrong in this whole validate process, an error will 
      be generated and returned to the caller.</para>

      <para>The following styles are defined :</para>

      <table frame="none" tocentry="1" >
      <title>Validation Styles</title>
      <tgroup cols="2">
        <thead>
          <row>
            <entry>Style</entry>
            <entry>Description</entry>
          </row>
        </thead>
        <tbody>
          <row>
            <entry>AnyName:</entry>
            <entry>Any object name not being a datareference or string, which 
            can not be validated. Example: CLEAR CONTAINER Main. Main is here a 
            container on the current screen. At validate time we don't know this 
            name of the current screen and container 'Main' can not further be 
            validated.</entry>
          </row>
          <row>
            <entry>ControlFunctionName:</entry>
            <entry>Any name of a built-in control function. Example: CONTROL cancel</entry>
          </row>
          <row>
            <entry>MathFunction:</entry>
            <entry>Math functions like sin(1) or abs(L-value)</entry>
          </row>
          <row>
            <entry>MathOperator:</entry>
            <entry>Math Operators like + - >= etc.</entry>
          </row>
          <row>
            <entry>Numeric:</entry>
            <entry>Any numeric value.</entry>
          </row>
          <row>
            <entry>ObjectName <parameter>NameOfObject</parameter>:</entry>
            <entry>Validation of a base object. The name of the object will be lifted
            from the style name. Examples: ObjectNameDataDictionary</entry>
          </row>
          <row>
            <entry>SingleDataReference:</entry>
            <entry>Any DataReference that can hold a single value. Examples: 
            L-Value P-size(2) C-MaxWeight</entry>
          </row>
          <row>
            <entry>SingleDataReferenceWrite:</entry>
            <entry>Any non-read-only SingleDataReference.</entry>
          </row>
          <row>
            <entry>GroupDataReference:</entry>
            <entry>Any DataReference that can hold a group of Data Dictionaries.
             like Records and VariableGroups. Examples: R-Size H-Selection</entry>
          </row>
          <row>
            <entry>GroupDataReferenceWrite:</entry>
            <entry>Any non-read-only GroupDataReference.</entry>
          </row>
          <row>
            <entry>Static:</entry>
            <entry>Hardcoded value. An attribute "Value=" need to be added
            containing the value.</entry>
          </row>
          <row>
            <entry>String:</entry>
            <entry>Any text between double quotes (" ").</entry>
          </row>
          <row>
            <entry>UnsignedInteger:</entry>
            <entry>Any whole positive number.</entry>
          </row>
          <row>
            <entry>Comparator:</entry>
            <entry><![CDATA[Compare values: = < <= > >= <>]]></entry>
          </row>
        </tbody>
      </tgroup>
      </table>

    </sect1>

    <sect1 id="prolinga-validate-validate_commands">
      <title>Validate Commands</title>

      <para>Validate Commands are used to send out a request to the validate service 
      to have some 4GL logic validated or to check for the physical presence of a
      member Object. A response will be send back. Behind the 
      scenes, the validate service will communicate with the Repository service to 
      retrieve and store the data involved.</para>

      <para>Validate Commands have the following format:</para>

<programlisting><![CDATA[
<ProLinga>
  <Validate Version="1.0" >
    <Command Name="]]><parameter>command</parameter><![CDATA[" Mode="Request/Response" SessionId="]]><parameter>unique_id</parameter><![CDATA[">
      <Object Application="]]><parameter>appn</parameter><![CDATA[" Type="]]><parameter>type</parameter><![CDATA[" Name="]]><parameter>name</parameter><![CDATA["/>
      . . .
      . . .
    </Command>
  </Validate>
</ProLinga>
]]></programlisting>


      <para>The following Validate Commands are available:</para>

      <itemizedlist>
        <listitem><para>TransformOnly</para></listitem>
        <listitem><para>Validate</para></listitem>
        <listitem><para>Ping</para></listitem>
      </itemizedlist>

      <sect2 id="prolinga-validate-vc_transformonly">
        <title>TransformOnly</title>

        <para>This setting only applies to Logic and it skips the validation step after 
        transforming the 4GL logic into an XML document. The transformed document will 
        get stored in the repository as type "RunControl".</para>

        <para>Example TransformOnly Request:</para>

<programlisting><![CDATA[
<ProLinga>
  <Validate Version=”1.0” >
    <Command Name=”TransformOnly” Mode=”Request”>
      <Object Application=”Advance” Type="Logic" Name=”Main”/>
    </Command>
  </Validate>
</ProLinga>
]]></programlisting>

        <para>Example TransformOnly Response:</para>

<programlisting><![CDATA[
<ProLinga>
  <Validate Version=”1.0” >
    <Command Name=”TransformOnly” Mode=”Response” Status="OK">
      <Object Application=”Advance” Type="Logic" Name=”Main”/>
    </Command>
  </Validate> 
</ProLinga>
]]></programlisting>
        <para/>

      </sect2>

      <sect2 id="prolinga-validate-vc_validate">
        <title>Validate</title>

        <para>Validation is implemented for Constant, Index, Logic, Record, Table, 
        Variable and VariableGroup. Other objects will simply be ignored.</para>

        <para>Example Validate Request:</para>

<programlisting><![CDATA[
<ProLinga>
  <Validate Version=”1.0” >
    <Command Name=”Validate” Mode=”Request”>
      <Object Application=”Advance” Type="Constant" Name=”EOF”/>
    </Command>
  </Validate>
</ProLinga>
]]></programlisting>

        <para>Example Validate Response:</para>

<programlisting><![CDATA[
<ProLinga>
  <Validate Version=”1.0” >
    <Command Name=”Validate” Mode=”Response” Status="OK">
      <Object Application=”Advance” Type="Constant" Name=”EOF”/>
    </Command>
  </Validate> 
</ProLinga>
]]></programlisting>
        <para/>
      </sect2>

      <sect2 id="prolinga-validate-vc_ping">
        <title>Ping</title>

        <para>The ping command can be used to test if a validate host is on-line
        and responding to requests.</para>

        <para>Example Ping Request:</para>

<programlisting><![CDATA[
<ProLinga>
  <Validate Version="1.0">
    <Command Name="Ping" Mode="Request"/>
  </Validate>
</ProLinga>
]]></programlisting>

        <para>Example Ping Response:</para>

<programlisting><![CDATA[
<ProLinga>
  <Validate Version="1.0">
    <Command Name="Ping" Mode="Response" Status="Ok"/>
  </Validate>
</ProLinga>
]]></programlisting>

        <para>Additional error information from the underlying SOAP layer will be 
        presented as well in the response document in case of an error.</para>

      </sect2>

    </sect1>

    <sect1 id="prolinga-validate-error_handling">
      <title>Error Handling</title>

      <para>As soon as something goes wrong when processing a request, an error is 
      generated and put into the response document. The status of the response will 
      be set to "Error" or "Warning" depending on the severity of the error. In 
      case of an error, processing will abort immediately, while in case of a 
      warning processing continues.</para>

      <para>An error has the following format:</para>

<programlisting><![CDATA[
<Error Id=”12345”>
  <Severity>Error/Warning</Severity>
  <Description>Short description</Description>
  <ExternalDescription>An external error text if available</ExternalDescription>
</Error>
<ValidateErrors>
  <ValidateError LineNo="logic_line_no" ArgumentNo="argument_no">
    <Severity>Error/Warning</Severity>
    <Id>syntax_error_id</Id>
    <Description>error description</Description>
    <Details>additional details</Details>
  </ValidateError>
    . . .
    . . .
</ValidateErrors>
]]></programlisting>

      <para>Example response when trying to validate a constant with a non exisiting data dictionary:
      </para>

<programlisting><![CDATA[
<ProLinga>
  <Validate Version="1.0">
    <Command Name="Validate" Mode="Response" Status="Error">
      <Object Application="Advance" Type="Constant" Name="Test2">
        <Error Id="30010">
          <Severity>Error</Severity>
          <Description>Contains Validate Errors</Description>
          <ExternalDescription></ExternalDescription>
        </Error>
        <ValidateErrors>
          <ValidateError LineNo="0" ArgumentNo="1">
           <Severity>Error</Severity>
           <Id>40009</Id>
           <Description>Invalid Data Dictionary Name</Description>
           <Details>Namexxx</Details>
          </ValidateError>
        </ValidateErrors>
      </Object>
    </Command>
  </Validate>
</ProLinga>
]]></programlisting>

       <para>The "External" element will contain any error text passed on from
       the O/S or 3rd party products.</para>

       <para>The following errors are defined:</para>

        <table frame="all" tocentry="1" >
        <title>Errors</title>
        <tgroup cols="3">
          <thead>
            <row>
              <entry>Error Id</entry>
              <entry>Severity</entry>
              <entry>Description</entry>
            </row>
          </thead>
          <tbody>
            <row>
              <entry>30000</entry>
              <entry>Ok</entry>
              <entry>No Error</entry>
            </row>
            <row>
              <entry>30001</entry>
              <entry>Error</entry>
              <entry>Error parsing document</entry>
            </row>
            <row>
              <entry>30002</entry>
              <entry>Error</entry>
              <entry>Empty document</entry>
            </row>
            <row>
              <entry>30003</entry>
              <entry>Error</entry>
              <entry>Invalid root element</entry>
            </row>
            <row>
              <entry>30004</entry>
              <entry>Error</entry>
              <entry>Invalid validate XML file</entry>
            </row>
            <row>
              <entry>30005</entry>
              <entry>Warning</entry>
              <entry>No document match</entry>
            </row>
            <row>
              <entry>30006</entry>
              <entry>Warning</entry>
              <entry>Document not found</entry>
            </row>
            <row>
              <entry>30007</entry>
              <entry>Warning</entry>
              <entry>Document already deleted</entry>
            </row>
            <row>
              <entry>30008</entry>
              <entry>Error</entry>
              <entry>Can not parse return string</entry>
            </row>
            <row>
              <entry>30009</entry>
              <entry>Error</entry>
              <entry>Can not write document to repository</entry>
            </row>
            <row>
              <entry>30010</entry>
              <entry>Error</entry>
              <entry>Contains Validate Errors</entry>
            </row>
            <row>
              <entry>30011</entry>
              <entry>Error</entry>
              <entry>Invalid object document layout</entry>
            </row>
            <row>
              <entry>30012</entry>
              <entry>Warning</entry>
              <entry>Object does not need to be validated</entry>
            </row>
          </tbody>
        </tgroup>
        </table>

       <para>The following 4GL Syntax errors are defined:</para>

        <table frame="all" tocentry="1" >
        <title>4GL Syntax Errors</title>
        <tgroup cols="3">
          <thead>
            <row>
              <entry>Error Id</entry>
              <entry>Severity</entry>
              <entry>Description</entry>
            </row>
          </thead>
          <tbody>
            <row>
              <entry>40000</entry>
              <entry>Ok</entry>
              <entry>No Error</entry>
            </row>
            <row>
              <entry>40001</entry>
              <entry>Error</entry>
              <entry>No language validation document</entry>
            </row>
            <row>
              <entry>40002</entry>
              <entry>Error</entry>
              <entry>Invalid logic command</entry>
            </row>
            <row>
              <entry>40003</entry>
              <entry>Error</entry>
              <entry>Invalid number of arguments</entry>
            </row>
            <row>
              <entry>40004</entry>
              <entry>Error</entry>
              <entry>Invalid argument</entry>
            </row>
            <row>
              <entry>40005</entry>
              <entry>Error</entry>
              <entry>Valid argument, invalid as closing argument</entry>
            </row>
            <row>
              <entry>40006</entry>
              <entry>Error</entry>
              <entry>Structure control command defined outside structure</entry>
            </row>
            <row>
              <entry>40007</entry>
              <entry>Error</entry>
              <entry>Structure close command defined outside structure</entry>
            </row>
            <row>
              <entry>40008</entry>
              <entry>Error</entry>
              <entry>Missing structure close command</entry>
            </row>
            <row>
              <entry>40009</entry>
              <entry>Error</entry>
              <entry>Invalid Data Dictionary name</entry>
            </row>
            <row>
              <entry>40010</entry>
              <entry>Error</entry>
              <entry>Invalid Record name</entry>
            </row>
            <row>
              <entry>40011</entry>
              <entry>Error</entry>
              <entry>Invalid Index Name</entry>
            </row>
            <row>
              <entry>40012</entry>
              <entry>Error</entry>
              <entry>Invalid Data Source Name</entry>
            </row>
            <row>
              <entry>40013</entry>
              <entry>Error</entry>
              <entry>Invalid Logic Name</entry>
            </row>
          </tbody>
        </tgroup>
        </table>

    </sect1>

    <sect1 id="prolinga-validate-multiple_vcs">
      <title>Multiple Validate Commands</title>

      <para>It is possible to combine VCs in one single request. There will be
      one response file, but with results for every command, unless an error has
      been encountered before the end of processing. The format is as follows:
      </para>

<programlisting><![CDATA[
<ProLinga>
  <Validate Version=”1.0”>
    <Command Name="]]><parameter>command</parameter><![CDATA[" Mode="Request">
      <Object Application="]]><parameter>appn</parameter><![CDATA[" Type="]]><parameter>type</parameter><![CDATA[" Name="]]><parameter>name</parameter><![CDATA[">
        ...
        ...
      </Object>
      <Object Application="]]><parameter>appn</parameter><![CDATA[" Type="]]><parameter>type</parameter><![CDATA[" Name="]]><parameter>name</parameter><![CDATA[">
        ...
        ...
      </Object>
    </Command>
  </Validate>
</ProLinga>
]]></programlisting>

      <para>Combining multiple VCs will result in better performance.</para>

    </sect1>
  </chapter>

  <chapter id="prolinga-validate-programming_notes">
    <title>ProLinga-Validate Programming Notes</title>

    <para>To test ProLinga-Validate, the best and easiest way is to
    use the binaries that come with the product. Configure so ProLinga-Validate is 
    running as a Web Service and use the client binary to send and
    receive Validate Commands. See the <ulink type="http"
    url="prolinga-validate-userguide.html">
    User Guide</ulink> section for more 
    details.</para>

    <para>To access the Validate engine from a C++ application,
    either network (SOAP) calls to send and receive Validate
    Commands over the network or the C++ API to
    link with the ProLinga-Validate library can be used.</para>

    <sect1 id="prolinga-validate-network_client">
      <title>Network Client</title>

      <para>To be able to send and receive ProLinga-Validate commands over 
      the network as SOAP calls from
      a C++ application, the application must link with the ProLinga-Soap
      Client Library (libprolingasoapclient). Details of how to do so are
      in the section "Programming Notes" of the ProLinga-Soap Project
      documentation. In the example you have to change the example
      XML request document with a valid Validate Command. Alternatively,
      have a look at the source code file <parameter>ValidateClient.cpp
      </parameter> in the <parameter>src</parameter> directory of
      ProLinga-Validate.</para>

      <para>When using this method, ProLinga-Validate must be running as 
      a Web Service.</para>

    </sect1>

    <sect1 id="prolinga-validate-validate_library">
      <title>Validate Library</title>

      <para>To be able to link directly with Validate from a C++
      application, the Validate Library (C++ API) can be used.</para>

      <para>A very basic example program using the Validate Library
      looks like this:</para>

<programlisting><![CDATA[
#include <prolinga/Validate.hpp>

int main()
{
        /*Init */
        xmlDocPtr docReq, docRes;
        xmlNodePtr curReq, curRes;
        xmlBufferPtr bufRes;
        PlValidate val;

        /* Open Validate Environment */
        val.validateOpen("./prolingavalcfg.xml");

        /* Create Validate Command */
        docReq = xmlNewDoc((const xmlChar *)"1.0");
        docReq->children = xmlNewDocNode(docReq, NULL, (const xmlChar *)"ProLinga", NULL);
        curReq = xmlDocGetRootElement(docReq);
        curReq = xmlNewTextChild (curReq, NULL, (const xmlChar *)"Validate", (const xmlChar *)"");
        xmlNewProp (curReq, (const xmlChar *)"Version", (const xmlChar *)"1.0");
        curReq = xmlNewTextChild (curReq, NULL, (const xmlChar *)"Command", (const xmlChar *)"");
        xmlNewProp (curReq, (const xmlChar *)"Name", (const xmlChar *)"Validate");
        xmlNewProp (curReq, (const xmlChar *)"Mode", (const xmlChar *)"Request");
        curReq = xmlNewTextChild (curReq, NULL, (const xmlChar *)"Object", (const xmlChar *)"");
        xmlNewProp (curReq, (const xmlChar *)"Application", (const xmlChar *)"MyOrder");
        xmlNewProp (curReq, (const xmlChar *)"Type", (const xmlChar *)"Logic");
        xmlNewProp (curReq, (const xmlChar *)"Name", (const xmlChar *)"RaiseStock");

        /* Process Validate Command */
        docRes = val.executeCommand(docReq);

        /* Print Response */
        bufRes = xmlBufferCreate();
        curRes = xmlDocGetRootElement(docRes);
        xmlNodeDump(bufRes, docRes, curRes, 0, 1);
        printf("%s\n", (char *)xmlBufferContent(bufRes));

        /* Close Validate Environment */
        val.validateClose();

        /* Free */
        xmlBufferFree(bufRes);
        xmlFreeDoc(docRes);
        xmlFreeDoc(docReq);

        /* Return */
        return 0;
}
]]></programlisting>

      <para>When running this application, a connection is made to the
      Validate environment. When opening this connection an argument with the path
      and name of the validate configuration file can be passed as
      an argument. The system then knows details as in which directory
      it can find the Language Validation file etc. The configuration file has
      to be in a certain format, which is explained further on. The Validate
      Command is then presented to the Validate process engine and a response
      is returned. This response is printed to to stdout (screen). The connection
      to Validate is closed and the program exits.</para>

      <para>After creating a connection using the openValidate class function, more
      than one VC can be executed without the need to close and open the Validate
      environment for every call. In fact performance wise this is the 
      prefered method.</para>

      <note>The C API of the libxml2 toolkit has been used in this example, 
      while it is probably better
      to use a C++ implementation of this toolkit as <ulink type="http"
      url="http://libxmlplusplus.sourceforge.net/">
      libxml++</ulink>. 
      Internal Validate code will
      be changed as the project progresses.</note>

      <para>The validate environment has to access the application
      Repository. This Repository can either be accessed via the network
      connecting to the Repository Web Service or it can be accessed 
      using a direct local path to the Repository.</para>

      <para>To compile the program using the network Repository access, 
      use the following command:</para>
<programlisting>
g++ validate_test.cpp -o validate_test `pkg-config --cflags --libs prolinga-validate`
</programlisting>

      <para>ProLinga-Soap Library <parameter>libprolingasoapclient</parameter> has to be available 
      for this option.</para>

      <para>To compile the program using direct local path Repository access, 
      use the following command:</para>
<programlisting>
g++ validate_test.cpp -o validate_test `pkg-config --cflags --libs prolinga-validate_nonet`
</programlisting>

      <para>ProLinga-Validate Library <parameter>libprolingavalidate_nonet</parameter> has to be available 
      for this option.</para>

      <para>You may need to set the environment variable PKG_CONFIG_PATH to 
      point to the directories where prolinga-validate.pc is located. 
      This can be directory <parameter>/usr/lib/pkgconfig</parameter> or
      directory <parameter>/usr/local/lib/pkgconfig</parameter> on GNU/Linux for
      example.
      </para>

      <para>ProLinga-Validate is built using various 3rd party open source packages.
      These packages need to be available at compile time for a sucessful result. See
      the <ulink type="http"
      url="prolinga-validate-build_instructions.html#prolinga-validate-dependencies">
      dependencies</ulink> and <ulink type="http"
      url="prolinga-validate-build.html#prolinga-validate-prerequisites">
      prerequisites</ulink> section for more details.</para>
    </sect1>

  </chapter>

  <chapter id="prolinga-validate-download">
    <title>Download ProLinga-Validate</title>

    <para>There are two types of product versions available for download:</para>

    <orderedlist>
      <listitem><para>Production Version</para></listitem>
      <listitem><para>Development Version</para></listitem>
    </orderedlist>

    <sect1 id="prolinga-validate-production_version">
      <title>Production Version</title>

      <para>The production version is an official product release. This is a
      stable completed version which should be used in production environments. At this 
      stage the product is only available as a source archive. Binary packages for a wide
      range of platforms will be available for download as the project progresses.
      Please visit the 
      <ulink type="http"
      url="http://download.prolinga.org">
      download page</ulink> for the latest details.</para>
    </sect1>

    <sect1 id="prolinga-validate-development_version">
      <title>Development Version</title>

      <para>The development version is a snapshot of the latest source files. Since
      it can contain bugs as part of "work in progress", this version should not
      be used in production environments. Only developers who want to help with
      further development of the ProLinga Projects should download this version. Please
      read the details at the <ulink type="http"
      url="prolinga-validate-subversion.html">Subversion section</ulink>
      of how to obtain the latest development version.</para>

    </sect1>

  </chapter>

  <chapter id="prolinga-validate-build">
    <title>Build ProLinga-Validate</title>

    <sect1 id="prolinga-validate-prerequisites">
      <title>Prerequisites</title>

      <para>ProLinga-Validate &version; has been built and tested
      on Fedora Core, Mandriva Linux,
      Debian, Ubuntu and openSUSE. The product should 
      compile and run successfully on
      other GNU/Linux distributions as well as UNIX.
      GNU gcc/g++ >= 3.3 compilers/tools are required
      for a successful build.
      </para>

      <para>Required 3rd party package(s) for a successful build:</para>
      <itemizedlist>
        <listitem>
          <para><ulink type="http"
          url="http://xmlsoft.org"><parameter>libxml2.</parameter></ulink>
          This product provides XML libraries.</para>
        </listitem>
        <listitem>
          <para><ulink type="http"
          url="http://www.prolinga.org"><parameter>ProLinga-Soap</parameter></ulink>
          This product provides a SOAP/XML engine.</para>
        </listitem>
      </itemizedlist>

      <para>Optional 3rd party package(s) for a successful build:</para>
      <itemizedlist>
        <listitem>
          <para><ulink type="http"
          url="http://www.prolinga.org"><parameter>ProLinga-Repository</parameter></ulink>
          This product provides an Application XML Repository. It is only required
          for direct linkage with the ProLinga-Repository Library. When choosing
          the (prefered) Web Services access method, this product is not 
          required.</para>
        </listitem>
        <listitem>
          <para>
          <ulink type="http"
          url="http://xmlsoft.org/XSLT"><parameter>xsltproc</parameter></ulink>. Command line processor.
          This package
          is only required to re-generate the HTML pages after making changes to the documentation.</para>
        </listitem>
      </itemizedlist>

      <sect2 id="prolinga-validate-3rd_party_download">
        <title>General Download and Installation Instructions 3rd Party Products.</title>

        <para>Assuming the directory /opt/builds will be used for 3rd party products, 
        then in general the following steps need to be taken to download and extract
        a 3rd party product source archive.</para>

      <itemizedlist>
        <listitem>
          <para>Download source tar/gz archive to /opt/builds/[product] Example: 
           place libxml2-<parameter>x.x.x</parameter>.tar.gz in /opt/builds/libxml2</para>
        </listitem>
        <listitem>
          <para>Use 'gunzip' to unzip the archive</para>
        </listitem>
        <listitem>
          <para>Use 'tar xvf [product.tar] to extract the archive. Example:
           tar xvf libxml2-<parameter>x.x.x.</parameter>tar.</para>
        </listitem>
        <listitem>
          <para>A new sub directory will be created with the new version of
          the product. Example: /opt/builds/libxml2/libxml2-<parameter>x.x.x</parameter>
          This way several versions of the same products can be installed next to
          each other.</para>
        </listitem>
      </itemizedlist>

      <para>For product specific installation instructions see following sections.</para>

      </sect2>

      <sect2 id="prolinga-validate-3rd_party_libxml2">
        <title>Libxml2:</title>
        <para>Product root dir: /opt/builds/libxml2</para>
        <para>Current version: 2.6.31</para>
        <para>Download:
        <ulink type="http"
        url="ftp://xmlsoft.org/libxml2/libxml2-2.6.31.tar.gz">
        ftp://xmlsoft.org/libxml2/libxml2-2.6.31.tar.gz</ulink></para>
        <para>Build Instructions:</para>

<programlisting>
cd /opt/builds/libxml2/libxml2-2.6.31
./configure --prefix=/opt/builds/libxml2/libxml2-2.6.31
make
make install
</programlisting>
        <para/>
      </sect2>

      <sect2 id="prolinga-validate-3rd_party_prolingarepository">
        <title>ProLinga-Repository:</title>
        <para>Product root dir: /opt/builds/prolinga</para>
        <para>Current version: 0.0.1</para>
        <para>Download:
        <ulink type="http"
        url="http://download.prolinga.org">
        http://download.prolinga.org</ulink></para>
        <para>Build Instructions:</para>

<programlisting>
cd /opt/builds/prolinga/prolinga-repository-0.0.1
./configure --prefix=/opt/builds/prolinga/prolinga-repository-0.0.1
make
make install
</programlisting>

       <note>See the ProLinga-Repository Project documentation for more installation
       information.</note>
        <para/>
      </sect2>

      <sect2 id="prolinga-validate-3rd_party_prolingasoap">
        <title>ProLinga-Soap:</title>
        <para>Product root dir: /opt/builds/prolinga</para>
        <para>Current version: 0.0.1</para>
        <para>Download:
        <ulink type="http"
        url="http://download.prolinga.org">
        http://download.prolinga.org</ulink></para>
        <para>Build Instructions:</para>

<programlisting>
cd /opt/builds/prolinga/prolinga-soap-0.0.1
./configure --prefix=/opt/builds/prolinga/prolinga-soap-0.0.1
make
make install
</programlisting>

       <note>See the ProLinga-Soap Project documentation for more installation
       information.</note>
        <para/>
      </sect2>

    </sect1>

    <sect1 id="prolinga-validate-build_instructions">
      <title>Build Instructions</title>

      <sect2 id="prolinga-validate-extracting_archive">
        <title>Extracting archive</title>

        <para>The product archive can be extracted to any desired directory
        using <parameter>unzip</parameter> (.zip file extension) or
        <parameter>gunzip</parameter> (.gz file extension)/
        <parameter>bunzip2</parameter> (.bz2 file extension) and 
        <parameter>tar</parameter>. After extracting, the following directories
        will be created:
        </para>

        <table frame="all" tocentry="0" >
        <title>Directory Structure.</title>
        <tgroup cols="2">
          <thead>
            <row>
              <entry>Directory</entry>
              <entry>Description</entry>
            </row>
          </thead>
          <tbody>
            <row>
              <entry>&PRODUCT;-&version;</entry>
              <entry>Product version root directory.</entry>
            </row>
            <row>
              <entry>&PRODUCT;-&version;/config</entry>
              <entry>Config build information.</entry>
            </row>
            <row>
              <entry>&PRODUCT;-&version;/doc</entry>
              <entry>Documentation.</entry>
            </row>
            <row>
              <entry>&PRODUCT;-&version;/src</entry>
              <entry>All source and internal header files.</entry>
            </row>
            <row>
              <entry>&PRODUCT;-&version;/tests</entry>
              <entry>Self tests.</entry>
            </row>
            <row>
              <entry>&PRODUCT;-&version;/prolinga</entry>
              <entry>External (API) header files.</entry>
            </row>
          </tbody>
        </tgroup>
        </table>

      </sect2>

      <sect2 id="prolinga-validate-compiling_linking">
        <title>Compiling and Linking</title>

        <para>To build the product go to the product root directory and run the 
        configure script. For default installation in /usr/local type:</para>

<programlisting>
./configure
</programlisting>

        <para>To install into another directory type:</para>

<programlisting>
./configure --prefix=<parameter>/any/dirname/</parameter>
</programlisting>

        <para>To link with ProLinga-Repository and build library
        <parameter>libprolingavalidate_nonet</parameter>, type:</para>

<programlisting>
./configure --enable-local-repository
</programlisting>

        <para>For all other configure options, type:</para>

<programlisting>
./configure --help
</programlisting>

        <para>After running the configure script, the product can be build with:</para>

<programlisting>
make
</programlisting>

        <para>To run the optional self-test type:</para>

<programlisting>
make check
</programlisting>

        <para>After compilation, the binaries, libraries and header files can be 
        installed with:</para>

<programlisting>
make install
</programlisting>

        <para>You may need root access for this last option.</para>

        <para>By default, HTML documentation pages are available in
        the doc/html directory. These pages are generated from 
        <ulink type="http"
        url="http://www.docbook.org">DocBook</ulink> XML file format
        files in /doc. To re-generate the HTML pages from these files type: </para>

<programlisting>
make html
</programlisting>

        <para>The command line XSLT processor <parameter>xsltproc</parameter> must be
        available from $PATH to be able to generate the HTML documentation.</para>

      </sect2>

      <sect2 id="prolinga-validate-dependencies">
        <title>Dependencies</title>

        <para>Many of the ProLinga Projects are dependent on 3rd party libraries.
        These (non system) dependencies of ProLinga-Validate are outlined below. 
        If these 3rd party
        products are not installed in either /usr/bin, /usr/lib, /usr/include
        or /usr/local/bin, /usr/local/lib, /usr/local/include, the additional
        configure option needs to be provided when building.</para>

        <table frame="all" tocentry="1" >
        <title>Dependencies</title>
        <tgroup cols="3">
          <thead>
            <row>
              <entry>Dependency</entry>
              <entry>Version</entry>
              <entry>Configure Option</entry>
            </row>
          </thead>
          <tbody>
            <row>
              <entry>libxml2</entry>
              <entry>>=2.6.5</entry>
              <entry>--with-libxml-prefix=<parameter>/path/to/libxml2</parameter></entry>
            </row>
            <row>
              <entry>ProLinga Repository</entry>
              <entry>>=0.0.1</entry>
              <entry>--with-prolingarepository-prefix=<parameter>/path/to/prolingarepository</parameter></entry>
            </row>
            <row>
              <entry>ProLinga-Soap</entry>
              <entry>>=0.0.1</entry>
              <entry>--with-prolingasoap-prefix=<parameter>/path/to/prolingasoap</parameter></entry>
            </row>
          </tbody>
        </tgroup>
        </table>
        <para></para>

      </sect2>

      <sect2 id="prolinga-validate-choose_build">
        <title>Choosing the right type of build</title>

        <para>The default configuration options provide libraries which 
        can be used both to develop/debug as to run the product. However better builds 
        are possible for a dedicated development or production environment.</para>

        <para>In <emphasis>production</emphasis> environments, builds are needed which contain minimal (debug) 
        overhead, so they are fast and small. To build such binaries/libraries, the 
        --enable-final options can be used. Example:</para>

<programlisting>
./configure --enable-final
</programlisting>

        <para>The enable-final flag is configured to be used with GCC environments only. 
        If access to more compilers become available over time, the enable-flag will be 
        ported to those compilers as well.</para>

        <para>In <emphasis>development</emphasis> environments, builds are needed producing warnings, enabling
        maximum debugging info etc. Several options are available here.</para>

        <itemizedlist>
           <listitem>
             <para>--enable-warnings : Set all compiler warning flags</para>
           </listitem>
           <listitem>
             <para>--enable-debug : Enable all debug messages</para>
           </listitem>
           <listitem>
             <para>--enable-gprof : Enables profiling with gprof (GCC only)</para>
           </listitem>
        </itemizedlist>

      </sect2>

    </sect1>

  </chapter>

  <chapter id="prolinga-validate-development">
    <title>Further development of ProLinga-Validate</title>

    <para>All ProLinga Projects are under constant active development. This includes
    issues related to fixing bugs, increasing performance etc, as well as expanding
    the various projects with new features. This chapter provides information of
    all these types of tasks as well as details of how to join the development team.</para>

    <sect1 id="prolinga-validate-todo">
      <title>To-do List</title>

      <para>This section contains a list of work that needs to be done on the product.
      A more detailed and up to date list is available on the
      <ulink type="http" url="http://bugzilla.prolinga.org">ProLinga Bugzilla Server</ulink>.
      </para>

      <itemizedlist>
         <listitem>
           <para>Implement XML Schemas for validation. Libxml2 is finishing up XML schemas.
           If it is still too far away, start with DTD.</para>
         </listitem>
         <listitem>
           <para>ProLinga-Validate is written in C++. Libxml2 however is C only. There is a C++ wrapper
           for this XML parser library. Details at <ulink type="http"
           url="http://libxmlplusplus.sourceforge.net/">http://libxmlplusplus.sourceforge.net/</ulink>.
           </para>
         </listitem>
         <listitem>
           <para>Some strings/paths are hardcoded in the product. This all should be
           reviewed and be removed or made all configurable using a config file.</para>
         </listitem>
         <listitem>
           <para>Utilities. Archiver at the moment can only be used to initialize 
           the Repository. We should have options available as creating application 
           dump, reading application dump etc.</para>
         </listitem>
         <listitem>
           <para>Code review and cleanup. Make it more C++ Object Oriented.</para>
         </listitem>
         <listitem>
           <para>Logging. A simple logging mechanism has been implemented.</para>
         </listitem>
         <listitem>
           <para>Self-tests need to be developed for quality control.</para>
         </listitem>
         <listitem>
           <para>Porting to other platforms. (MS-Windows/Solaris?), so we can make a distribution
            available on a specific port if we need to.</para>
         </listitem>
         <listitem>
           <para>As enhancements, we should look into making ProLinga-Validate a more 
           useful product by itself, rather then "just" a project for the
           ProLinga environment.</para>
         </listitem>
         <listitem>
           <para> Add command line options to the binaries. At least a -? should be
           available.</para>
         </listitem>
       </itemizedlist>

    </sect1>

    <sect1 id="prolinga-validate-subversion">
      <title>Subversion</title>

      <para>A Subversion tree containing the latest project sources is available at
      <ulink type="http" url="http://svn.prolinga.org">http://svn.prolinga.org</ulink>.
      For access please contact the <ulink type="http"
      url="http://lists.prolinga.org">ProLinga Development team</ulink>.</para>

    </sect1>

    <sect1 id="prolinga-validate-bugzilla">
      <title>Bugzilla</title>

      <para>Bugzilla software development and bug tracking system to manage the ProLinga 
      projects is available at
      <ulink type="http" url="http://bugzilla.prolinga.org">http://bugzilla.prolinga.org</ulink>.
      For access please contact the <ulink type="http"
      url="http://lists.prolinga.org">ProLinga Development team</ulink>.</para>

    </sect1>

    <sect1 id="prolinga-validate-help_develop">
      <title>Help to Develop</title>

      <para>Are you ready to join the ProLinga development team? There are several ways you
      can help:</para>

      <itemizedlist>
         <listitem>
           <para>Use the product. Tell <ulink type="http"
           url="http://lists.prolinga.org">us</ulink> what you think, ideas, bugs etc.</para>
         </listitem>
         <listitem>
           <para>Fixing bugs. Visit the development section on the <ulink type="http"
           url="http://www.prolinga.org">ProLinga Web Site</ulink>,
           choose a
           bug, fix it and send <ulink type="http"
           url="http://lists.prolinga.org">us</ulink> the code changes.
           </para>
         </listitem>
         <listitem>
           <para>Enhancements. Have a look at the enhancement section of the
           <ulink type="http"
           url="prolinga-validate-development.html#prolinga-validate-todo">to-do list</ulink>
           and let <ulink type="http"
           url="http://lists.prolinga.org">us</ulink> know which new feature you
           want to help to develop.</para>
         </listitem>
         <listitem>
           <para>Porting. To be successful it is essential that the ProLinga Projects
           are available on a wide range of platforms. We need help in porting and
           testing as well as providing binary releases for many different platforms.
           Let <ulink type="http"
           url="http://lists.prolinga.org">us</ulink> know if and how you can help out.
           </para>
         </listitem>
         <listitem>
           <para>Real world examples. Are you using ProLinga products or do you know people
           who are happily using it. Tell <ulink type="http"
           url="http://lists.prolinga.org">us</ulink> the story and provide some screenshots.
           </para>
         </listitem>
      </itemizedlist>

    </sect1>

  </chapter>

  <part id="prolinga-validate-API">
    <title>ProLinga-Validate C++ API</title>

    <partintro>
      <para>This section contains the API reference for ProLinga-Validate.  All
      the public interfaces are documented here.</para>
    </partintro>

    <!-- The API documentation -->
    &prolinga-validate-API;

  </part>

  <part id="prolinga-validate-userguide">
    <title>ProLinga-Validate User Guide</title>

    <partintro>
      <para>This section contains the user guide for the ProLinga-Validate. All
      the binaries are documented here.</para>
    </partintro>

    <!-- The API documentation -->
    &prolinga-validate-userguide;

  </part>

  <!-- The document license -->
  &fdl;

</book>
