17.16.1 Syntax
The syntax rules in this subclause follow the system shown in ISO/IEC 14977: literal text is surrounded by double-quotes (or by apostrophes); the left-square-bracket and right-square-bracket designate the start and end of an option; the left-curly-bracket and right-curly-bracket designate the start and end of a sequence of one-or- more items; the vertical-line indicates an alternative; and each rule ends with a semicolon. Whenever hyphen is used as the exception-symbol (as per ISO/IEC 14977), it is surrounded by white space, and further clarified by a comment.
The syntax rules below were derived from the field-specific rules in the detailed definitions shown in 17.16.5.. [Note: In order to produce an automated verifier, field-specific rules in subclauses 17.16.5. must also be considered. end note]
When used in narrative, production names are set in an italic style, as in comparison, field-argument, and switches.
The syntax of a field is as follows:
field=
field-type, [switches] ;
field-type=
date-and-time |
document-automation |
document-information |
document-property |
equations-and-formulas |
index-and-tables |
links-and-references |
mail-merge |
numbering |
user-information |
form-field | user-defined-field
user-defined-field=
letter, {letter} ;
date-and-time=
"CREATEDATE" | "DATE" | "EDITTIME" | "PRINTDATE" |
"SAVEDATE" | "TIME" ;
document-automation=
"COMPARE", comparison |
"DOCVARIABLE", field-argument |
"GOTOBUTTON", 2 * field-argument |
"IF", comparison, 2 * field-argument |
"MACROBUTTON", 2 * field-argument |
"PRINT", field-argument |
"PRIVATE" ;
document-information=
"FILENAME" | "FILESIZE" | "LASTSAVEDBY" | "NUMCHARS"
"NUMPAGES" | "NUMWORDS" | "TEMPLATE" ;
document-property=
"AUTHOR", [field-argument] |
"COMMENTS", [field-argument] |
"DOCPROPERTY", docprop-category |
"KEYWORDS", [field-argument] |
"SUBJECT", [field-argument] |
"TITLE", [field-argument] ;
equations-and-formulas=
"=", expression |
"ADVANCE" |
"SYMBOL", field-argument ;
index-and-tables=
"INDEX" |
"RD", field-argument |
"TA" |
"TC", field-argument |
"TOA" |
"TOC" |
"XE", field-argument ;
links-and-references=
"AUTOTEXT", field-argument |
"AUTOTEXTLIST", field-argument |
"BIBLIOGRAPHY" |
"CITATION", field-argument |
"HYPERLINK", field-argument |
"INCLUDEPICTURE", field-argument |
"INCLUDETEXT", field-argument, [field-argument] |
"LINK", 2 * field-argument, [field-argument] |
"NOTEREF", field-argument |
"PAGEREF", field-argument |
"QUOTE", field-argument |
["REF"], field-argument | (* see [17.16.5.51](../../../17/17.16/17.16.5/17.16.5.51/) *)
"STYLEREF", field-argument ;
mail-merge=
"ADDRESSBLOCK" |
"ASK", 2 * field-argument |
"DATABASE" |
"FILLIN", [field-argument] |
"GREETINGLINE" |
"MERGEFIELD", field-argument |
"MERGEREC" |
"MERGESEQ" |
"NEXT" |
"NEXTIF", comparison |
"SET", 2 * field-argument |
"SKIPIF", comparison ;
numbering=
"LISTNUM", [field-argument] |
"PAGE" |
"REVNUM" |
"SECTION" |
"SECTIONPAGES" |
"SEQ", identifier, [field-argument] ;
user-information=
"USERADDRESS", [field-argument] |
"USERINITIALS", [field-argument] |
"USERNAME", [field-argument] ;
form-field=
"FORMCHECKBOX" | "FORMDROPDOWN" | "FORMTEXT" ;
bookmark-name=
identifier ;
cell-name=
column-name, row-name ;
cell-range=
cell-name, colon, cell-name |
row-name, colon, row-name |
column-name, colon, column-name ;
cell-reference=
cell-name |
cell-name, { comma, cell-name } |
cell-range ;
character=
as defined by the production Char in the XML 1.0 specification, [2.2](../../../2/2.2/).
colon=
":" ;
column-name=
letter + [{letter}] ; (* allowing for A, … Z, AA, …., ZZ, AAA, … column
naming *)
comma=
"," ;
comparison=
expression, comparison-operator, expression ;
comparison-operator=
"=" | "<>" | "<" | "<=" | ">" | ">=" ;
constant=
number ;
date-and-time-formatting-switch=
"\@", switch-argument (* as defined in [17.16.4.1](../../../17/17.16/17.16.4/17.16.4.1/) *) ;
docprop-category=
"AUTHOR" | "BYTES" | "CATEGORY" | "CHARACTERS" |
"CHARACTERSWITHSPACES" | "COMMENTS" |
"COMPANY | CREATETIME" | "HYPERLINKBASE" |
"KEYWORDS" | "LASTPRINTED" | "LASTSAVEDBY" |
"LASTSAVEDTIME" | "LINES" | "MANAGER" |
"NAMEOFAPPLICATION" | "ODMADOCID" | "PAGES" |
"PARAGRAPHS" | "REVISIONNUMBER"| "SECURITY" |
"SUBJECT" | "TEMPLATE" | "TITLE" |
"TOTALEDITINGTIME" | "WORDS" ;
double-quote=
'"' ; (* one double-quote character *)
expression=
"(", expression, ")" |
comparison |
constant |
prefix-operator, expression |
expression, infix-operator, expression |
field |
bookmark-name, [cell-reference] |
function |
cell-reference |
text |
double-quote, text, double-quote ;
field-argument=
text |
double-quote, text, double-quote ;
field-specific-switch=
"\", character, [character], [field-argument] ;
(* no whitespace is permitted after the backslash,
also see definition of each field in [17.16.5](../../../17/17.16/17.16.5/) *)
formatting-switch=
date-and-time-formatting-switch |
numeric-formatting-switch |
general-formatting-switch ;
fractional-part=
decimal-digit {decimal-digit} ;
full-stop=
"." ; (* also known as “period” *)
function=
"ABS(", expression, ")" |
"AND(", expression, "," expression, ")" |
"AVERAGE(", list, ")" |
"COUNT(", list, ")" |
"DEFINED(", expression, ")" |
"FALSE" |
"INT(", expression, ")" |
"MAX(", list, ")" |
"MIN(", list, ")" |
"MOD(", expression, ",", expression, ")" |
"NOT(", expression, ")" |
"OR(", expression, ",", expression, ")" |
"PRODUCT(", list, ")" |
"ROUND(", expression, ",", expression, ")" |
"SIGN(", expression, ")" |
"SUM(", list, ")" |
"TRUE" ;
general-formatting-switch=
"\*", switch-argument ; (* as defined in [17.16.4.3](../../../17/17.16/17.16.4/17.16.4.3/) *)
identifier=
character + [{character}] ;
infix-operator=
"-" | "^" | "*" | "/" | "%" | "+" | "-" | "=" |
"<>" | "<" | "<=" | ">" | ">=" ; (* see [17.16.3.3](../../../17/17.16/17.16.3/17.16.3.3/) *)
letter=
"a"|"b"|"c"|"d"|"e"|"f"|"g"|"h"|"i"|"j"|"k"|"l"|"m"|
"n"|"o"|"p"|"q"|"r"|"s"|"t"|"u"|"v"|"w"|"x"|"y"|"z"|
"A"|"B"|"C"|"D"|"E"|"F"|"G"|"H"|"I"|"J"|"K"|"L"|"M"|
"N"|"O"|"P"|"Q"|"R"|"S"|"T"|"U"|"V"|"W"|"X"|"Y"|"Z" ;
list=
expression, {list-separator, expression} ;
list-separator=
comma | semicolon ;
(* depending on the document’s listSeparator, [17.15.1.56](../../../17/17.15/17.15.1/17.15.1.56/)*)
number=
whole-number-part, [full-stop] |
full-stop, fractional-part |
whole-number-part, full-stop, fractional-part ;
numeric-formatting-switch=
"\#", switch-argument ; (* as defined in [17.16.4.2](../../../17/17.16/17.16.4/17.16.4.2/) *)
prefix-operator=
"-" ;
row-name=
whole-number-part ;
semicolon=
";" ;
switch-argument=
text |
double-quote, text, double-quote ;
switches=
{field-specific-switch}, [formatting-switch]
text=
character, {character} ;
whole-number-part=
decimal-digit, {decimal-digit} ;
Formulas (also called expressions) are discussed in 17.16.3, constants are discussed in 17.16.3.1, bookmarks are discussed in 17.16.3.2, operators are discussed in 17.16.3.3, functions are discussed in 17.16.3.4, table cell references are discussed in 17.16.3.5, and formatting switches are discussed in 17.16.4.
The semantics of a field having a user-defined-field type are unspecified.
If the text in a field-argument or switch-argument contains white space, the delimiting double-quote characters shall be present; otherwise, they are optional. To include a double-quote character in text, it shall be preceded with a backslash (). [Example: The field argument “"name"” results in the argument’s actually being “name”. end example] To include a backslash character in text, it shall be preceded with another backslash (). [Example: File system pathnames on some systems use a backslash as a directory separator, as in the field
INCLUDETEXT "E:\\ReadMe.txt"
in which case, each such separator needs to be preceded with a backslash, as shown above. end example]
Arbitrary amount of white space can occur before the first token, after the last token, and between successive tokens, including no white space at all, except that in a field-specific-switch, no white space is permitted between the initial “\” token and the character that follows it.
[Example: Here are examples of some fields:
DATE
DATE \@ "dddd, MMMM dd, yyyy"
DATE \@ "dddd, MMMM dd, yyyy"
The field result of all three is today’s date: The first field uses some implementation-defined format and the Gregorian calendar; the second field uses the specified format and the Gregorian calendar; and the third field uses the specified format and the Hijri lunar calendar. When rendered in a US-English context on December 31, 2005, the results of these fields were as follows:
12/31/2005
Saturday, December 31, 2005
AsSabt, Thoul Ki'dah 30, 1426
end example]
The names of fields are alphabetic tokens [Example: Some field-type names are ASK, COMMENTS, NEXT, and SET. end example]. These tokens are called field-type names. Field-type names are case-insensitive. [Example: The field-type names DATE, Date, dAtE, and date are equivalent. end example]
The characters immediately following the “\” are equivalent. end example]
in field-specific-switchare case-insensitive. [Example: \b and \B
There is no ordering of field-specific-switch entries in switches.