📄 syntax.htm
字号:
<HTML>
<HEAD>
<TITLE>Syntax</TITLE>
</HEAD>
<BODY BACKGROUND="bar_products.gif" BGCOLOR="white">
<UL>
<UL>
<P><IMG SRC="syntax.GIF" ALIGN="BOTTOM" BORDER="0">
<HR ALIGN="CENTER">
<UL>
<LI><A HREF="#general"><FONT SIZE="4"><B>General Rules</B></FONT></A><P>
<LI><A HREF="#elements"><FONT SIZE="4"><B>CGML Tags</B></FONT></A><P>
<UL>
<LI><A HREF="#object"><B>Object Tags</B></A><P>
<LI><A HREF="#alias"><B>Alias Tags</B></A><P>
<LI><A HREF="#identifier"><B>Identifier Tags</B></A><P>
</UL>
<LI><A HREF="#predef"><FONT SIZE="4"><B>About Pre-Defined Elements</B></FONT></A><P>
<UL>
<LI><A HREF="#lookup"><B>Pre-Defined Lookup Objects</B></A><P>
<LI><A HREF="#AliasAndIdent"><B>Pre-Defined Aliases and Identifiers</B></A><P>
</UL>
<LI><A HREF="#ConLogic"><FONT SIZE="4"><B>Conditional Logic</B></FONT></A><P>
<LI><A HREF="#ItLogic"><FONT SIZE="4"><B>Iterative Logic</B></FONT></A><P>
<UL>
<LI><A HREF="#arrayops"><B>Standard Array Operators</B></A><P>
<LI><A HREF="#arrays"><B>Pre-Defined Arrays</B></A><P>
<LI><A HREF="#ArrObjTag"><B>Referencing Array Object Tags</B></A><P>
</UL>
<LI><A HREF="#control"><FONT SIZE="4"><B>Control Commands</B></FONT></A><P>
<UL>
<LI><A HREF="#output"><B>Specifying Output</B></A><P>
<LI><A HREF="#SetVandA"><B>Set Variables and Aliases</B></A><P>
<LI><A HREF="#execute"><B>Execute Statements</B></A><P>
<LI><A HREF="#create"><B>Create Reusable Text Objects</B></A><P>
<LI><A HREF="#include"><B>Include Statements</B></A><P>
<LI><A HREF="#stop"><B>STOP Command</B></A><P>
</UL>
<LI><A HREF="#array_object"><B>Array Object Tags</B></A><P>
<LI><A HREF="#examples"><B>Examples</B></A><P>
</UL>
<P>
<HR ALIGN="CENTER">
</P>
<P><FONT SIZE="5"><B>CGML SYNTAX REFERENCE</B></FONT></P>
<P>This section provides detailed information about the syntax of the Code Generation Markup Language from Quest Software.</P>
<P>
<HR ALIGN="CENTER">
</P>
<P><A NAME="general"></A><FONT SIZE="5" FACE="Arial"><I><B> General Rules</B></I></FONT></P>
<UL>
<LI>CGML commands and tagged text are not case-sensitive.<P>
<LI>CGML comment lines begin with the # character.<P>
<LI>All text not contained inside tags are reproduced in the generation process "as is", including leading
blanks, blank lines and special characters.<P>
</UL>
<P>
<HR ALIGN="CENTER">
</P>
<P><A NAME="elements"></A><FONT SIZE="5" FACE="Arial"><I><B> CGML Tags</B></I></FONT></P>
<UL>
<LI><A HREF="#object"><B>Object Tags</B></A><P>
<LI><A HREF="#alias"><B>Alias Tags</B></A><P>
<LI><A HREF="#identifier"><B>Identifier Tags</B></A><P>
</UL>
<P>Just as with HTML, CGML uses "tag" characters to indicate "special text" or commands to
the CGML processor. There are four kinds of tags:</P>
<P>
<TABLE BORDER="0" CELLPADDING="7" CELLSPACING="1" WIDTH="702" FRAME="BORDER">
<TR>
<TD WIDTH="14%" VALIGN="TOP">command tag</TD>
<TD WIDTH="86%" VALIGN="TOP">Indicates that the text inside the tag characters is a CGML command or syntax element, such as IF or FOREACH. Example:<BR>
<BR>
<PRE>[IF]</PRE></TD>
</TR>
<TR>
<TD WIDTH="14%" VALIGN="TOP">object tag</TD>
<TD WIDTH="86%" VALIGN="TOP">Indicates that the text inside the tag characters is to be substituted dynamically with information that is looked
up in the PL/Generator Object Information Repository. Example:<BR>
<BR>
<PRE>[colname]</PRE></TD>
</TR>
<TR>
<TD WIDTH="14%" VALIGN="TOP">alias tag</TD>
<TD WIDTH="86%" VALIGN="TOP">Indicates that the text inside the tag characters is an alias for another string previously. Example:<BR>
<BR>
<PRE>{updproc}</PRE></TD>
</TR>
<TR>
<TD WIDTH="14%" VALIGN="TOP">identifier tag</TD>
<TD WIDTH="86%" VALIGN="TOP">
<P>Indicates that the text between the tags should be treated as an identifier, a <I>name </I>within the driver's
code language. This means that identifier validation will occur. Example:
<PRE> ^{updproc}^</PRE>
<PRE> ^{[colname]}^</PRE>
</TD>
</TR>
</TABLE>
</P>
<P>As you can easily discern from the last examples, you can and often will combine the different kinds of tags.</P>
<P>Please remember that CGML is not a <I>formatting</I> language. You will not find tags for setting text to bold,
underlined, etc. Instead, the tags are used to generate code or text based on data sources.</P>
<P>
<HR ALIGN="CENTER">
</P>
<P><A NAME="object"></A><FONT SIZE="4" FACE="Arial"><B> Object Tags</B></FONT></P>
<P>Use object tags to indicate that the text inside the tag characters is to be substituted dynamically with information
that is looked up in the PL/Generator Object Information Repository. These tags are also used to delineate CGML
commands.</P>
<P>The default object tags are</P>
<PRE> [ ] </PRE>
<P>While it is possible to change the characters used for the object tags, we recommend that you leave them defined
with the default values.</P>
<P>The following statement shows the use of the object tags to specify a conditional statement (a CGML command),
in this case asking "If there is at least one primary key column then...":</P>
<PRE>
[IF]havepkycols
...
[ENDIF]
</PRE>
<P>See the section titled "Pre-Defined Lookup Elements" for the list of all elements defined in the Table
Encapsulation driver (and therefore available to all users of PL/Generator).</P>
<P>You can define your own objects to be used inside tags for lookups; see " Defining or Extending Drivers"
for more information on this advanced topic.</P>
<P>
<HR ALIGN="CENTER">
</P>
<P><A NAME="alias"></A><FONT SIZE="4" FACE="Arial"><B> Alias Tags</B></FONT></P>
<P>The alias tags are used to allow for text substitutions. An alias is used most commonly to assign a shortcut
or abbreviation for a complex sequence/combination of object tags and alias tags. The default alias tags are:</P>
<PRE>{ } </PRE>
<P>While it is possible to change the characters used for the alias tags, we recommend that you leave them defined
with the default values.</P>
<P>Here is an example of an alias tag for the Update Procedure:</P>
<PRE>/FONT></PRE>
<P>The "updproc" alias is replaced at generation time with this string:</P>
<PRE>{PLG>procpre}{PLG>upd}{PLG>procsuf}</PRE>
<P>PLG> is the prefix used by PL/Generator for all pre-defined aliases. As you can see, aliases can be nested
within other aliases. PL/Generator will substitute those aliases recursively until only "plain text"
remains.</P>
<P>See the section titled "Pre-Defined Aliases and Identifiers" for the list of all aliases defined in
the Table Encapsulation driver (and therefore available to all users of PL/Generator).</P>
<P>You can define your own aliases to be used inside tags for dynamic substitution; see " Defining or Extending
Drivers" for more information on this advanced topic. You should never define aliases that start with "PLG>".</P>
<P>
<HR ALIGN="CENTER">
</P>
<P><A NAME="identifier"></A><FONT SIZE="4" FACE="Arial"><B> Identifier Tag</B></FONT></P>
<P>Every language has rules for its identifiers, the names of elements in the language. CGML can be used to generate
text in the language of <I>your </I>choice. The Table Encapsulation driver, for example, generates PL/SQL code.</P>
<P>The rules for a PL/SQL identifier are as follows:</P>
<UL>
<LI>Maximum of 30 characters<P>
<LI>Must start with a letter and after that contain only letters, digits, #, $ or _.<P>
</UL>
<P>If you would like PL/Generator to automatically validate your identifiers (constructed at runtime and sometimes
in ways that will break your identifier rules), you must surround your text (usually an alias) with the identifier
tag (it is the same character before and after the text). The default character is:</P>
<PRE> ^ </PRE>
<P>as in:</P>
<PRE> ^{insert_procedure}^ </PRE>
<P>While it is possible to change the character used for the identifier tag, we recommend that you leave it defined
with the default value.</P>
<P>PL/Generator will take the following action when it detects an identifier that is invalid:</P>
<UL>
<LI>Truncate the name to fit within its length boundaries.<P>
<LI>Substitute the object name for the object abbreviation (if provided for that object).<P>
<LI>Guarantee a unique identifier by truncating and appending sequence numbers until a unique name is constructed.<P>
</UL>
<P>So those are the different types of tags. You will mostly be wanting to assemble CGML from existing, defined
objects and aliases.</P>
<P>The next sections provide you with a list of those elements.</P>
<P>
<HR ALIGN="CENTER">
</P>
<P><A NAME="predef"></A><FONT SIZE="5" FACE="Arial"><I><B> About Pre-Defined Elements</B></I></FONT></P>
<P><FONT FACE="Arial">Whenever you use CGML, you will be generating text based on a <I>driver</I>. A driver consists
of a set of pre-defined elements and arrays that you can access in your CGML text. There are three kinds of elements:
lookup objects, aliases and identifiers.</FONT></P>
<P><A NAME="lookup"></A><FONT SIZE="4" FACE="Arial"><I>Pre-Defined Lookup Objects</I></FONT></P>
<P>Unless you are building an entirely new driver from the ground up, you will be working within the context of
or based upon the existing Table Encapsulation driver (this is the case, for example, when you run the PLGCGML.genFile
procedure). This driver has a large set of pre-defined object tags.</P>
<P>You can view the current set of object tags at any time by executing the query found in the showobjtags.sql
script (output is written to objtags.txt). Here are a few lines you will see when you run the script:</P>
<P>
<TABLE BORDER="0" CELLSPACING="10">
<TR>
<TD>[GENDIR]</TD>
<TD></TD>
<TD>Name of directory to which text will be generated</TD>
</TR>
<TR>
<TD>[GENPKYONLY]</TD>
<TD></TD>
<TD>TRUE if user cannot supply primary key</TD>
</TR>
<TR>
<TD>[GENPKY]</TD>
<TD></TD>
<TD>TRUE if primary key is to be generated</TD>
</TR>
<TR>
<TD>[HAVECONSCOL]</TD>
<TD></TD>
<TD>TRUE if at least one in Array of check constraint columns</TD>
</TR>
</TABLE>
</P>
<P>Note: some of the object tags can only be used within an array loop.</P>
<P>
<HR ALIGN="CENTER">
</P>
<P><A NAME="AliasAndIdent"></A><FONT SIZE="4" FACE="Arial"><I> Pre-Defined Aliases and Identifiers</I></FONT></P>
<P>Unless you are building an entirely new driver from the ground up, you will be working within the context of
or based upon the existing Table Encapsulation driver (this is the case, for example, when you run the PLGCGML.genFile
procedure). This driver has a large set of pre-defined aliases and identifiers.</P>
<P>You can view the current set of alias tags at any time by executing the query found in the showaliastags.sql
script (output is written to aliastags.txt). Here are a few lines you will see when you run the script:</P>
<P>
<TABLE BORDER="0" CELLSPACING="10">
<TR>
<TD>{PLG>BYPKYCUR}</TD>
<TD></TD>
<TD>Cursor returning specified columns from all rows</TD>
</TR>
<TR>
<TD>{PLG>CHKFUNC}</TD>
<TD></TD>
<TD>Returns TRUE if check constraint valid</TD>
</TR>
<TR>
<TD>{PLG>CLOSEALLPROC}</TD>
<TD></TD>
<TD>Procedure closes all open cursors defined in the package</TD>
</TR>
</TABLE>
</P>
<P>
<HR ALIGN="CENTER">
</P>
<P><A NAME="ConLogic"></A><FONT SIZE="5" FACE="Arial"><I><B> Conditional Logic</B></I></FONT></P>
<P>CGML offers a set of command tags to implement conditional logic. The various formats are shown below:</P>
<PRE> [IF] expression
[ELSIF] expression
[ELSE]
[ENDIF]label
[IFNOT] expression
[ELSIFNOT] expression
[ELSE]
[ENDIF]label
</PRE>
<P>where <B>expression </B>follows one of the following formats</P>
<PRE> expr
expr1[EQ]expr2
expr1[AND]expr2 ([AND]expr3...)
expr1[OR]expr2([OR]expr3...)
expr[ISNOTNULL] </PRE>
<P>where expr , expr1 and expr2 follow these rules:</P>
<UL>
<LI>If there are alias tags around the expression, then the alias is replaced with its actual value and then treated
as a literal value.<P>
<LI>For the [EQ] operator, if there are object tags around expr or expr1 , or no tags at all, then the expression
is treated as an object tag and evaluated by the PL/Generator engine. The expr2 string is treated as a literal,
unless tags are applied explicitly to the string.<P>
</UL>
<UL>
<LI>With [AND] and [OR], the strings to both the left and right of the operator are treated implicitly as object
tags, unless alias tags are included explicitly.<P>
<LI>You can have multiple [AND] clauses in a statement, and you can have multiple [OR] clauses in a statement,
but you cannot mix [AND]s and [OR]s together in the same conditional clause.<P>
</UL>
<P>The label is an optional "comment" you can add after the [ENDIF] command to document the logical clause
that is terminating. And here are some examples of the above formats "at work":</P>
<P>1. Perform generation only if the table has a primary key defined.</P>
<PRE> [if]havepkycols
/* Primary Key present. */
[endif]
</PRE>
<P>2. If there are ten columns in the primary key...</P>
<PRE> [if]countpkycols[eq]10
/* Ten primary key columns! */
[endif]
</PRE>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -