Server Reference Guide : ASOLib--OpenROAD Server Library : XML Parameters for Use with GSCPs : XML and 4GL Data
 
Share this page          
XML and 4GL Data
XML (eXtensible Markup Language) is a text-based format for representing information in a self-describing hierarchical structure. An XML document contains entity tags, which are usually paired into an opening and closing tag. Entity tags are contained within a top-level root tag pair. The data between entity tags is usually a mixture of other paired entity tags and associated data, or simply data. These entity tags consist of character data between the '<' and '>' characters. The structure of an XML document can be strictly enforced by the use of a DTD. A document type definition is a description of how XML entity tags may be arranged in an XML document based on the definition. XML parsers can use the DTD to test whether an XML document conforms to the DTD; a document that conforms is called valid.
The data passed into and out of a 4GL service call procedure consists of a list of parameters that can be simple scalars or objects and, hence, can be hierarchical in nature. By mapping the parameter structure into a related XML document structure, you can send and retrieve parameter data as XML documents. The 4GL parameter names are represented as XML entity names, and 4GL parameter values are represented as XML entity values. When requested (in the client call) XML-to-4GL mapping occurs automatically. It is available for method GSCPs and for procedure GSCPs. It is not available for regular user-written 4GL SCPs.
Example: How You Can Map 4GL Parameter Data to XML
The following example illustrates how 4GL parameter data is mapped to XML tags and vice versa. Suppose that you have a database that contains relationships between authors, publishers, editions, and books. The business user classes in the OpenROAD Server have been mapped on to this data and have the following structure.
The attributes of user class uc_author are:
i_id        = INTEGER,
i_age       = INTEGER,
v_name      = VARCHAR(32),
The attributes of user class uc_publisher are:
v_name      = VARCHAR(32),
The attributes of user class 'uc_book' are:
arr_UCEdition = ARRAY OF uc_edition,
v_title       = VARCHAR(32),
UCauthor      = uc_author,
The attributes of user class uc_edition are:
i_issue_no  = INTEGER,
i_year      = INTEGER,
m_cost      = MONEY,
UCpublisher = uc_publisher,
This example uses a Business Policy Manager named uc_author_pm. Certain methods have been selected for exposure, and so GSCPs have been generated for these methods automatically.
Note:  XML-to-4GL mapping is also available for procedure GSCPs if a stateless approach is preferred.
One of the GSCPs generated is scp_GetAuthorAndBooks, which maps to method GetAuthorAndBooks. The GSCP contains all of the underlying method's parameters (plus others added automatically). One of the method's parameters is an input parameter p_i_author_id, which represents an ID of an author. The data returned from this method is a list of books that have been published by the author, together with the author's details.
The parameter list for method GetAuthorAndBooks looks like this:
p_i_author_id  = INTEGER,
b_UCAuthor     = uc_author,
b_arr_UCBooks  = ARRAY of uc_book,
The p_i_author_id parameter is an input parameter, and b_UCAuthor and b_arr_UCBooks constitute output parameters.