| SQmlTM Publishing Overview | |||||||||||||||
This section provides the very basics of SQmlTM Publishing:
SGML, or Standardized General Markup Language, is an ISO international standard for electronic document exchange. SGML has been used for a number of years and is especially well suited for complex documentation projects that require multiple authors writing many chapters and/or volumes. SGML focuses on document structure, that is, the set of elements that comprise a document and the relationship between those elements. For example, a typical manual includes the elements: sections, section headings, and paragraphs. These elements form a hierarchy where primary elements, such as sections, consist of simpler elements, such as headings and paragraphs. SGML simplifies the task of creating a standard look and feel for documentation that spans multiple volumes. Some of its advantages are that SGML:
Therefore, where authors of any documents for the same project insert ordered list tags, for example, the ordered lists will look the same in all the documents when formatted.
HTML, or Hypertext Markup Language, is a form of SGML. Like SGML, it is a tag-based, platform-independent language for describing structured documents. Unlike SGML, HTML cannot be customized to accommodate the varying needs of specific documentation projects, and HTML does not provide powerful document management tools. Although it lacks the power and flexibility of SGML, HTML is an excellent language to use for World Wide Web publishing. Almost all of its elements are readable by any Web browser on any platform, and it is simpler to learn and to use. Like SGML, each HTML document element (with some exceptions) has a beginning tag and an ending tag, enclosed in angled brackets. A forward slash marks an ending tag. For example, in HTML, the first part of this section might look like: <H3>HTML</H3> <P>HTML is a subset of SGML (etc.)</P> <P>Like SGML, each HTML document element (etc.)</P> HTML also supports online hypertext links, which is especially important for Web authoring. It provides the means to easily link to other documents, incorporate graphics, and access other resources, such as databases, across the Internet. See Useful References in the Preface of this guide for a list of books and Web sites that provide information and tutorials on SGML and HTML. SQL, or Structured Query Language, is a standard language used to retrieve information from various types of relational database systems, such as Oracle, Sybase, Informix, Microsoft SQL Server, Access, and others. SQL also allows users to define data and manipulate data in a relational database. Relational database management systems store information in tables. SQL enables users to access data by specifying the data they want to find within the table columns. In SQL, a SELECT statement is used to retrieve information in the rows of a specified database table. A WHERE statement used with the SELECT statement enables users to narrow the search for data so that SELECT retrieves only data that meets specified conditions. The conditions are specified using logical operators, which are the symbols for equal to, not equal to, less than, greater than, less than or equal to, and greater than or equal to. Following is a very simple example of a relational database table: CustomerTable
The following SQL query: SELECT FirstName, LastName FROM CustomerTable WHERE Description = 'Muppet'; would return (in FirstName, LastName order, as typed in the SELECT statement): Oscar Grouch The query returns the first name and last name of Oscar Grouch and Cookie Monster, but not Bugs Bunny or Daffy Duck. This is because the SELECT statement includes a WHERE element that asks for the return of the FirstName and LastName column contents for only the rows that have Muppet in the Description column. (And, because SQL is case-sensitive, all items in the SELECT, FROM, and WHERE statements must be capitalized the same as in the database table.) Of course, SQL provides methods for performing much more complex queries than this example, as well as for manipulating data within database tables. See Useful References in the Preface of this guide for a list of books and Web sites that provide information and tutorials on SQL. How SQmlTM Builds on SGML/HTML and SQL SQmlTM is a vehicle for embedding SQL query statements into SGML or HTML source documents. SQmlTM functions much like a wrapper for an SQL query (or a set of SQL queries). SQmlTM source code looks very much like what it is, a combination of SGML/HTML and SQL, with unique elements that provide its functionality. Like SGML/HTML, most SQmlTM statements include beginning and ending codes, which are compatible with standard SGML/HTML. Within the beginning and ending codes are SQmlTM elements, which specify connection or query information. How did SQmlTM--this cohesion of SGML/HTML and SQL-evolve? Evolution of SQmlTM Agave developed SQmlTM to fill their need for an electronic database publishing tool that met the following requirements:
Choosing SGML as a document source filled the first two requirements. However, because SGML alone does not support the extraction of database information using SQL, the team developed additional requirements for the database extraction function:
That is, the tool should not require a dozen command line parameters to run. It should not be a multi-stage filter. It should simply allow the user to expand the document in a single operation, preferably from within the editor. Based on these needs, Agave developed a tool to create SQL expansions within SGML source documents. This tool lent itself to the product name SQmlTM. Embedding SQL queries into SGML (or HTML) source requires mapping of relational data into a hierarchical database. SGML is hierarchical. SQL is relational. Hierarchical and relational databases are akin to each other, but have many distinct differences. To map relational SQL data into the hierarchical SGML format, Agave SQmlTM implements an approach where queries are nested so that joins are done across queries rather than in a single query. Implementation of Nested Queries This section uses the following tables as examples to illustrate the nested query approach to mapping relational data into a hierarchical database:
Product_line {
product_line char(10),
product_line_desc char(80),
sales_phone_num char(12) }
Product {
product_name char(20),
product_line char(10),
product_desc char(80)}
Using the nested query approach requires two queries:
select product_line, product_line_desc
into :prodline, :prodlinedesc
from product_line
where...;
select product_name, product_desc
into :prodname, :proddesc
from product
where product.product_line = :prodline
and ...;
The first query is embedded in the hierarchy while the second is embedded in the hierarchy. For every Product Line returned by the first query, a separate second query is run. The relational/hierarchical mapping is clear and easy to use and understand. TM Elements">SQmlTM Processing Elements SQmlTM uses processing elements as SQL holders. SQmlTM processing elements are SGML elements in appearance and use. SQmlTM elements have meaning only to the SQmlTM parser and are normally discarded in the processing step. This should not pose a problem for most common SGML editors. The primary SQmlTM processing elements are:
The SQML.CONNECT element specifies the userid, password, and database to connect to and retrieve data from: <SQML.CONNECT USER="username" PASS="password" DATABASE="dbdescription"> The SQL.BLOCK element performs a simple query replacement of the element. For example: <BODY> <SQL.BLOCK TEXT="select product_name from product"> </BODY> might become: <BODY>Key system PBX Large PBX Carrier CSU/DSU RTX-1 PC-Ether M-Hub Hub Sr. Switch Boss Super Browse </BODY> The SQL.ITER element provides the relational/ hierarchical data mapping scheme. SQL.ITER is syntactically similar to SQL.BLOCK: <SQL.ITER TEXT="select product_name into :prodname from product>" </SQL.ITER> The difference is how it is treated by the parser. It is an Iterative Element. More on Iterative Elements SQL.ITER is an SQmlTM Iterative Element. An Iterative Element (start-end pair), as used in SQmlTM, specifies a block of SGML that will be repeated some number of times. In this case the block is repeated once for each record returned by the query. In addition, Iterative Elements can be nested to provide hierarchical/relational mapping. Example The following simple example may be used to generate a book of several hundred pages. SQmlTM sets virtually no predetermined document size limitations.
<TITLE>Price Book</TITLE>
<SQML.CONNECT USER="user" PASSWORD="passwd">
<BODY>
<SQL.ITER TEXT="select product_line, product_line_desc
into :prodline, :prodlinedesc
from product_line"
<PRODLINE>&prodline;</PRODLINE>
<PRODLINEDESC>&prodlinedesc;</PRODLINEDESC>
<SQL.ITER TEXT="select product_name, product_desc
into :prodname, :proddesc
from product
where product.product_line = :prodline">
<PRODNAME>&prodname;</PRODNAME>
<PRODDESC>&proddesc;</PRODDESC>
</SQL.ITER>
</SQL.ITER>
</BODY>
The <SQML.CONNECT USER="user" PASSWORD="passwd"> statement connects to the database. Note the use of general entities as place holders for the column values returned from the queries. A Few Guidelines Iterative Elements may be extended from any source of SGML data-mapping. For example, the document source does not necessarily have to be an SQL database. The document source could be flat files, an Object database, or even an SGML database. In general, SQmlTM can be used to retrieve information for any SGML or HTML document that relies on structured data contained in an SQL database. However, keep the following guidelines in mind:
|
|||||||||||||||
|
© copyright 1997 Agave Software Design, Inc. |