Table of contentsAppendices |
5.9 ExpressionsExpressionsAll property value specifications in attributes within an XSL stylesheet can be expressions. These expressions represent the value of the property specified. The expression is first evaluated and then the resultant value is used to determine the value of the property. Property Context[top]Property ContextProperties are evaluated against a property-specific context. This context provides:
NOTE: When a type instance (e.g., a string, a keyword, a numeric, etc.) is recognized in the expression it is evaluated against the property context. This provides the ability for specific values to be converted with the property context's specific algorithms or conversions for use in the evaluation of the expression as a whole. For example, the "auto" enumeration token for certain properties is a calculated value. Such a token would be converted into a specific type instance via an algorithm specified in the property definition. In such a case the resulting value might be an absolute length specifying the width of some aspect of the formatting object. In addition, this allows certain types like relative numerics to be resolved into absolute numerics prior to mathematical operations. All property contexts allow conversions as specified in [expr.value.conv] . Evaluation Order[top]Evaluation OrderWhen a set of properties is being evaluated for a specific formatting object in the formatting object tree there is a specific order in which properties must be evaluated. Essentially, the "font-size" property must be evaluated first before all other properties. Once the "font-size" property has been evaluated, all other properties may be evaluated in any order. When the "font-size" property is evaluated, the current font-size for use in evaluation is the font-size of the parent element. Once the "font-size" property has been evaluated, that value is used as the current font-size for all property contexts of all properties value expressions being further evaluated. Basics[top]Basics
Function Calls[top]Function Calls
Numerics[top]NumericsA numeric represents all the types of numbers in an XSL expression. Some of these numbers are absolute values. Others are relative to some other set of values. All of these values use a floating-point number to represent the number-part of their definition. A floating-point number can have any double-precision 64-bit format IEEE 754 value [IEEE754] . These include a special "Not-a-Number" (NaN) value, positive and negative infinity, and positive and negative zero. See Section 4.2.3 of [JLS] for a summary of the key rules of the IEEE 754 standard.
The following operators may be used with numerics:
NOTE: NOTE: NOTE: Numeric Expressions
NOTE: If a non-numeric value is used in an [AdditiveExpr] and there is no property context conversion from that type into an absolute numeric value, the expression is invalid and considered an error. Absolute Numerics[top]Absolute NumericsAn absolute numeric is an absolute length which is a pair consisting of a [Number] and a [UnitName] raised to a power. When an absolute length is written without a unit, the unit power is assumed to be zero. Hence, all floating point numbers are a length with a power of zero. Each unit name has associated with it an internal ratio to some common internal unit of measure (e.g., a meter). When a value is written in a property expression, it is first converted to the internal unit of measure and then mathematical operations are performed. In addition, only the mod, addition, and subtraction operators require that the numerics on either side of the operation be absolute numerics of the same unit power. For other operations, the unit powers may be different and the result should be mathematically consistent as with the handling of powers in algebra. A property definition may constrain an absolute length to a particular power. For example, when specifying font-size, the value is expected to be of power "one". That is, it is expected to have a single powered unit specified (e.g., 10pt). When the final value of a property is calculated, the resulting power of the absolute numeric must be either zero or one. If any other power is specified, the value is an error. Relative Numerics[top]Relative NumericsRelative lengths are values that are calculated relative to some other set of values. When written as part of an expression, they are either converted via the property context into an absolute numeric or passed verbatim as the property value. It is an error if the property context has no available conversion for the relative numeric and a conversion is required for expression evaluation (e.g., within an add operation). Percents[top]PercentsPercentages are values that are counted in 1/100 units. That is, For example, a value of "110%" on a "font-size" property would be evaluated to mean 1.1 times the current font size. Such a definition of the allowed conversion for percentages is specified on the property definition. If no conversion is specified, the resulting value is a percentage. Relative Lengths[top]Relative LengthsA relative length is a unit-based value that is measured against the
current value of the There is only one relative unit of measure, the "em". The definition of "1em" is equal to the current font size. For example, a value of "1.25em" is 1.25 times the current font size. When an em measurement is used in an expression, it is converted according to the font-size value of the current property's context. The result of the expression is an absolute length. See [font-size] . Strings[top]StringsStrings are represented either as [literals] or as an [enumeration token] . All properties contexts allow conversion from enumeration tokens to strings. See [expr.value.conv] . Colors[top]ColorsA color is a set of values used to identify a particular color from a color space. Only RGB [sRGB] (Red, Green, Blue) and ICC (International Color Consortium) [ICC] colors are included in this Recommendation. RGB colors are directly represented in the expression language using a hexadecimal notation. ICC colors can be specified through an rgb-icc function. Colors can also be specified through the system-color function or through conversion from an [EnumerationToken] via the property context. Keywords[top]KeywordsKeywords are special tokens in the grammar that provide access to calculated values or other property values. The allowed keywords are defined in the following subsections. inherit[top]inheritThe property takes the same computed value as the property for the formatting object's parent object. NOTE: Lexical Structure[top]Lexical StructureWhen processing an expression, white space ( [ExprWhitespace] ) may be allowed before or after any expression token even though it is not explicitly defined as such in the grammar. In some cases, white space is necessary to make tokens in the grammar lexically distinct. Essentially, white space should be treated as if it does not exist after tokenization of the expression has occurred. The following special tokenization rules must be applied in the order specified to disambiguate the grammar:
Expression Lexical Structure
Expression Value Conversions[top]Expression Value ConversionsValues that are the result of an expression evaluation may be converted into property value types. In some instances this is a simple verification of set membership (e.g., is the value a legal country code). In other cases, the value is expected to be a simple type like an integer and must be converted. It is not necessary that all types be allowed to be converted. If the expression value cannot be converted to the necessary type for the property value, it is an error. The following table indicates what conversions are allowed.
The specific conversion to be applied is property specific and can be found in the definition of each property. NOTE: Definitions of Units of Measure[top]Definitions of Units of MeasureThe units of measure in this Recommendation have the following definitions:
Pixels[top]PixelsXSL interprets a 'px' unit to be a request for the formatter to choose a device-dependent measurement that approximates viewing one pixel on a typical computer monitor. This interpretation is follows:
NOTE: |