Advanced XFA Picture Clauses

Both the provider-disabled native FormCalc evaluators (from 2.1207.14) and the optional QuickJS engine support these picture clauses in FormCalc events, calculate and validate scripts, and validate.picture formatTest checks

Format(picture, value) produces display text and Parse(picture, text) produces canonical values; locale selection, quoted literals and alternatives follow FormCalc Locale and Picture Functions

Numeric precision and scientific notation

SymbolBehaviour
EFormats a signed base-10 exponent after the mantissa; the leading and fractional digit positions determine mantissa precision, with rounding carry applied before the exponent is emitted
8Retains the expressed fractional precision of supplied decimal text, including trailing zeros; absent fractional digits omit the decimal radix, and a run of 8 symbols can preserve more supplied fractional digits than its length

Scientific mantissas use at most 15 digit positions; exponent magnitudes and decimal expansion are bounded to 10000, and nonfinite values produce empty text

Precision pictures preserve quoted literals before and after fractional positions; percent scaling shifts the original decimal text without losing trailing zeros through binary floating point conversion

Pass decimal strings when their expressed precision matters; JavaScript numeric values have already undergone binary floating point conversion before formatting

Format("num{99.999E}", 12345)             // 12.345E+3
Parse("num{99.999E}", "12.345E-2")       // 0.12345
Format("num{zzz,zz9.8}", "12345.0000")   // 12,345.0000
Parse("num{zz9.8}", "12.3400")           // 12.3400
Format("num{zz9.8%}", "0.1250")          // 12.50%

Zero and null alternatives

The native FormCalc evaluators and the QuickJS provider support zero and null masks as standalone clauses and as ordered alternatives

zero{...} formats numeric zero, and null{...} formats a null value. These clauses accept numeric picture symbols, quoted labels and empty output masks. Put the special cases before the general number format to give them priority

Parse returns numeric zero for a matched zero mask and null for a matched null mask. The null clause also accepts empty input. An unmatched input returns empty text unless another alternative matches

Format("null{'n/a'} | zero{'none'} | num{9.9}", 0)  // none
Parse("null{'n/a'} | zero{9} | num{9.9}", "n/a")     // null

Ordinal and week dates

SymbolBehaviour
J, JJJDay of year, from 1 to 366; JJJ pads to three digits and parsing validates leap years
ENumeric weekday from 1 for Sunday to 7 for Saturday; EEE and EEEE continue to use abbreviated and full locale weekday names
eISO weekday from 1 for Monday to 7 for Sunday
WWISO week from 01 to 53; week 01 contains 4 January, and a year in this picture is the ISO week year
wMonth week from 0 to 5, beginning on Sunday; the first week must contain at least four days from the month

Parsing ordinal or week dates returns the corresponding ISO calendar date; contradictory day, month, weekday or week values return empty text

Four-digit early years are constructed without the JavaScript century adjustment, including years 0000 to 0099; historical alternate eras remain outside these pictures

Format("date{YYYY-JJJ}", "2024-02-29")   // 2024-060
Parse("date{YYYY-WW-e}", "2020-53-5")    // 2021-01-01
Format("date{w}", "2004-07-03")          // 0

Additional clock variants

k and kk express a 0–11 hour within the meridiem; K and KK express a 1–24 hour within the day, with 24 representing midnight

Use A with k clocks to distinguish AM and PM; lowercase z formats an ISO offset without a colon, zz uses a colon, and uppercase Z emits GMT or GMT with an explicit offset. Native and QuickJS parsing return signed offsets as +HH:MM or -HH:MM and UTC as Z

Global picture symbols

SymbolInput parsingOutput formatting
?Consumes one Unicode code pointProduces one space
*Consumes zero or more breakable whitespace charactersProduces one space
+Consumes one or more breakable whitespace charactersProduces one space

These symbols work within date, time, datetime, number and text pictures; quoted symbols remain literal characters, supplementary Unicode characters count as one character, and nonbreaking spaces are excluded from whitespace matching

Compound input parsing

Native and QuickJS-backed FormCalc can parse their own formatted datetime output when the date or time mask includes a quoted literal containing T. For example, datetime{'Today: 'YYYY-MM-DD'T'HH:MM:SS} reads Today: 2024-02-29T12:34:56 as 2024-02-29T12:34:56. A time mask can begin with minutes, such as MM:SS, and omitted hours default to zero

Compound date and time clauses combine into canonical ISO date-time text; repeated representations of the same value must agree, and literal delimiters are checked before accepting the input

Repeated scalar clauses must produce the same canonical number or text; incompatible category combinations, contradictory values, incomplete consumption or multiple distinct canonical results produce empty text

Compound parsing permits 64 parts, 8192 UTF-16 input units and 8192 parse attempts, whilst sharing the runtime operation and elapsed-time budgets; exceeding these limits fails the event transaction

Parse("date{YYYY-MM-DD} time{HH:MM:SS}", "2024-02-29 12:34:56")
// 2024-02-29T12:34:56
Parse("date{YYYYMMDD}time{HHMMSS}", "20240229123456")
// 2024-02-29T12:34:56

Runtime behaviour and current boundaries

Calculated fields and events use the same implementation and locale metadata; failed scripts restore document values and committed JavaScript state, and saved XDP data retains successful results

Full-width numeric and text masks, mixed precision-preserving 8 fractional slots, and wider or multi-width integer grouping (such as four-digit myriad and 2-2-3 lakh/crore grouping) are supported in the native evaluators; non-Gregorian historical eras remain outside scope

See Interactive XFA Widget Runtime for transaction, replay and operation budget behaviour