ArborX


<?showifdef>

Longname: show if def ined   Open the Documentation Legend
Released: 6.00 
Created: 6.00 
See also: <?showifnum> <?yank>
showstrings (n/a)

Summary
This command has been implemented primarily with SGML/XML type attributes in mind, to allow conditional processing of a show string, depending on whether an attribute is defined.
Example extract

The requirement was to display the words 'Authors:Dave' in the text stream only if name attribute was defined. Inside the author tag you would have the following:

Tx tx1: 0(00)c

...<author name="Dave" >...

St author: 0(36)c

<?showifdef "name"Authors:$^name#^>


Syntax (6.00)
<?showifdef  !:L?  inheritance:L? name:s  )  mode:L?  test:sw? action:sw >
!:L This will negate the normal result of the test. i.e. from 'show if defined' to 'show if not defined'.
inheritance:L

This parameter was implemented to control attribute inheritance when using XML in 3B2 and the showifdef command instead of XPath expressions to control attributes. The syntax is one of the following two options inserted within the double quotes of the attribute name parameter, but because this is a special character we must surround the entire item with a further set of single quotes in the form <?showifdef "'}id'"Show this>:

No default attribute inheritance from parent, get the attribute from the the current element only (or self).
Inherit attribute values from parent only not self.
name:s

The name of the attribute to test for must be present. In its simplest form, without any test the show string will be used if the attribute is present even if not given an explicit value. i.e.:

If <?showifdef "fred"Hello> is set inside the <body> style tag, it will display "Hello" for <body fred> or <body fred=1> but not for <body>.

mode:L
Ø  Just a string compare the value of name against action will be displayed if they match.
As above but does a case sensitive comparison.
A wild card comparison. i.e. <?showifdef "fred*=c*"Hello> will display "Hello" only if "fred" begins with a 'c' or a 'C'.
none  @*A case sensitive wild card comparison.
Tests the value of name with a regular expression. action will be displayed if a match for the regular expression is contained within the value of name. To test for an exact match, use '^' and '$' at the start and end of the regular expression. (see Technote 0011; Regular Expressions; 5.10a, for operators).
@/  A case sensitive regular expression match.
Tests the value of name with a verify string. i.e.: <?showifdef "fred#=1..5i> will test for a integer in the range, 1 to 5. <?showifdef "fred#=c> tests for a colour. <?showifdef "fred#=u> tests for a unit: e.g. 5mm, 7pt.
test:sw If present it must be preceded by an equals sign. This reacts differently according to any mode that is present.
action:sw Any applicable showstring or display text.

This command has numerous applications, some examples of which are shown below.

Example

If the 'id' attribute is defined in the <para id="..."> element, set the Xcounter 99 to 0 and the typeface to Times:

St para: 0(36)c

<?showifdef "id"[?show=x(99)][?tf="Times"]>

Example

If the 'gutter' attribute is defined in the <colspec gutter="..."> tag, show the table gutter command <?tbcolgut=?>, using the attributes value:

St colspec: 0(36)c

<?showifdef "gutter"$60#?tbcolgut==$^gutter#^$62#>

The use of variables in the resulting code requires the chevrons to be replaced with their ascii value in the form of $60#, and equals signs to be doubled up.
Example

If the 'name' attribute is defined in the <authors name="..."> tag. Then insert a showstring that will yank the text up to the </authors> tag, and insert the resulting yanked text into a reference tag called 'Authmn' preceded with the style tag <name_style>.

Tx1: 0(36)c

...<authors name="Chris">This manual was......</authors>

St authors: 0(36)c

<?showifdef "name"$60#?show "Authmn"\[name_style\]\$1,0,63y"/\\60\\\\47\\authors\\62\\/ci"$62#>

Note again the $60# as in the previous example and the double \\ in the search string, also the \[ & \] around the style tag, instructing Arbortext APP not to process yet. See also .

Document created on 08-Feb-2003 (revision 1)